ACF Photo Gallery Field - Version 1.6.2

Version Description

Download this release

Release Info

Developer navzme
Plugin Icon 128x128 ACF Photo Gallery Field
Version 1.6.2
Comparing to
See all releases

Version 1.6.2

LICENSE.txt ADDED
@@ -0,0 +1,339 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+ Preamble
10
+
11
+ The licenses for most software are designed to take away your
12
+ freedom to share and change it. By contrast, the GNU General Public
13
+ License is intended to guarantee your freedom to share and change free
14
+ software--to make sure the software is free for all its users. This
15
+ General Public License applies to most of the Free Software
16
+ Foundation's software and to any other program whose authors commit to
17
+ using it. (Some other Free Software Foundation software is covered by
18
+ the GNU Lesser General Public License instead.) You can apply it to
19
+ your programs, too.
20
+
21
+ When we speak of free software, we are referring to freedom, not
22
+ price. Our General Public Licenses are designed to make sure that you
23
+ have the freedom to distribute copies of free software (and charge for
24
+ this service if you wish), that you receive source code or can get it
25
+ if you want it, that you can change the software or use pieces of it
26
+ in new free programs; and that you know you can do these things.
27
+
28
+ To protect your rights, we need to make restrictions that forbid
29
+ anyone to deny you these rights or to ask you to surrender the rights.
30
+ These restrictions translate to certain responsibilities for you if you
31
+ distribute copies of the software, or if you modify it.
32
+
33
+ For example, if you distribute copies of such a program, whether
34
+ gratis or for a fee, you must give the recipients all the rights that
35
+ you have. You must make sure that they, too, receive or can get the
36
+ source code. And you must show them these terms so they know their
37
+ rights.
38
+
39
+ We protect your rights with two steps: (1) copyright the software, and
40
+ (2) offer you this license which gives you legal permission to copy,
41
+ distribute and/or modify the software.
42
+
43
+ Also, for each author's protection and ours, we want to make certain
44
+ that everyone understands that there is no warranty for this free
45
+ software. If the software is modified by someone else and passed on, we
46
+ want its recipients to know that what they have is not the original, so
47
+ that any problems introduced by others will not reflect on the original
48
+ authors' reputations.
49
+
50
+ Finally, any free program is threatened constantly by software
51
+ patents. We wish to avoid the danger that redistributors of a free
52
+ program will individually obtain patent licenses, in effect making the
53
+ program proprietary. To prevent this, we have made it clear that any
54
+ patent must be licensed for everyone's free use or not licensed at all.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ GNU GENERAL PUBLIC LICENSE
60
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
+
62
+ 0. This License applies to any program or other work which contains
63
+ a notice placed by the copyright holder saying it may be distributed
64
+ under the terms of this General Public License. The "Program", below,
65
+ refers to any such program or work, and a "work based on the Program"
66
+ means either the Program or any derivative work under copyright law:
67
+ that is to say, a work containing the Program or a portion of it,
68
+ either verbatim or with modifications and/or translated into another
69
+ language. (Hereinafter, translation is included without limitation in
70
+ the term "modification".) Each licensee is addressed as "you".
71
+
72
+ Activities other than copying, distribution and modification are not
73
+ covered by this License; they are outside its scope. The act of
74
+ running the Program is not restricted, and the output from the Program
75
+ is covered only if its contents constitute a work based on the
76
+ Program (independent of having been made by running the Program).
77
+ Whether that is true depends on what the Program does.
78
+
79
+ 1. You may copy and distribute verbatim copies of the Program's
80
+ source code as you receive it, in any medium, provided that you
81
+ conspicuously and appropriately publish on each copy an appropriate
82
+ copyright notice and disclaimer of warranty; keep intact all the
83
+ notices that refer to this License and to the absence of any warranty;
84
+ and give any other recipients of the Program a copy of this License
85
+ along with the Program.
86
+
87
+ You may charge a fee for the physical act of transferring a copy, and
88
+ you may at your option offer warranty protection in exchange for a fee.
89
+
90
+ 2. You may modify your copy or copies of the Program or any portion
91
+ of it, thus forming a work based on the Program, and copy and
92
+ distribute such modifications or work under the terms of Section 1
93
+ above, provided that you also meet all of these conditions:
94
+
95
+ a) You must cause the modified files to carry prominent notices
96
+ stating that you changed the files and the date of any change.
97
+
98
+ b) You must cause any work that you distribute or publish, that in
99
+ whole or in part contains or is derived from the Program or any
100
+ part thereof, to be licensed as a whole at no charge to all third
101
+ parties under the terms of this License.
102
+
103
+ c) If the modified program normally reads commands interactively
104
+ when run, you must cause it, when started running for such
105
+ interactive use in the most ordinary way, to print or display an
106
+ announcement including an appropriate copyright notice and a
107
+ notice that there is no warranty (or else, saying that you provide
108
+ a warranty) and that users may redistribute the program under
109
+ these conditions, and telling the user how to view a copy of this
110
+ License. (Exception: if the Program itself is interactive but
111
+ does not normally print such an announcement, your work based on
112
+ the Program is not required to print an announcement.)
113
+
114
+ These requirements apply to the modified work as a whole. If
115
+ identifiable sections of that work are not derived from the Program,
116
+ and can be reasonably considered independent and separate works in
117
+ themselves, then this License, and its terms, do not apply to those
118
+ sections when you distribute them as separate works. But when you
119
+ distribute the same sections as part of a whole which is a work based
120
+ on the Program, the distribution of the whole must be on the terms of
121
+ this License, whose permissions for other licensees extend to the
122
+ entire whole, and thus to each and every part regardless of who wrote it.
123
+
124
+ Thus, it is not the intent of this section to claim rights or contest
125
+ your rights to work written entirely by you; rather, the intent is to
126
+ exercise the right to control the distribution of derivative or
127
+ collective works based on the Program.
128
+
129
+ In addition, mere aggregation of another work not based on the Program
130
+ with the Program (or with a work based on the Program) on a volume of
131
+ a storage or distribution medium does not bring the other work under
132
+ the scope of this License.
133
+
134
+ 3. You may copy and distribute the Program (or a work based on it,
135
+ under Section 2) in object code or executable form under the terms of
136
+ Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+ a) Accompany it with the complete corresponding machine-readable
139
+ source code, which must be distributed under the terms of Sections
140
+ 1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+ b) Accompany it with a written offer, valid for at least three
143
+ years, to give any third party, for a charge no more than your
144
+ cost of physically performing source distribution, a complete
145
+ machine-readable copy of the corresponding source code, to be
146
+ distributed under the terms of Sections 1 and 2 above on a medium
147
+ customarily used for software interchange; or,
148
+
149
+ c) Accompany it with the information you received as to the offer
150
+ to distribute corresponding source code. (This alternative is
151
+ allowed only for noncommercial distribution and only if you
152
+ received the program in object code or executable form with such
153
+ an offer, in accord with Subsection b above.)
154
+
155
+ The source code for a work means the preferred form of the work for
156
+ making modifications to it. For an executable work, complete source
157
+ code means all the source code for all modules it contains, plus any
158
+ associated interface definition files, plus the scripts used to
159
+ control compilation and installation of the executable. However, as a
160
+ special exception, the source code distributed need not include
161
+ anything that is normally distributed (in either source or binary
162
+ form) with the major components (compiler, kernel, and so on) of the
163
+ operating system on which the executable runs, unless that component
164
+ itself accompanies the executable.
165
+
166
+ If distribution of executable or object code is made by offering
167
+ access to copy from a designated place, then offering equivalent
168
+ access to copy the source code from the same place counts as
169
+ distribution of the source code, even though third parties are not
170
+ compelled to copy the source along with the object code.
171
+
172
+ 4. You may not copy, modify, sublicense, or distribute the Program
173
+ except as expressly provided under this License. Any attempt
174
+ otherwise to copy, modify, sublicense or distribute the Program is
175
+ void, and will automatically terminate your rights under this License.
176
+ However, parties who have received copies, or rights, from you under
177
+ this License will not have their licenses terminated so long as such
178
+ parties remain in full compliance.
179
+
180
+ 5. You are not required to accept this License, since you have not
181
+ signed it. However, nothing else grants you permission to modify or
182
+ distribute the Program or its derivative works. These actions are
183
+ prohibited by law if you do not accept this License. Therefore, by
184
+ modifying or distributing the Program (or any work based on the
185
+ Program), you indicate your acceptance of this License to do so, and
186
+ all its terms and conditions for copying, distributing or modifying
187
+ the Program or works based on it.
188
+
189
+ 6. Each time you redistribute the Program (or any work based on the
190
+ Program), the recipient automatically receives a license from the
191
+ original licensor to copy, distribute or modify the Program subject to
192
+ these terms and conditions. You may not impose any further
193
+ restrictions on the recipients' exercise of the rights granted herein.
194
+ You are not responsible for enforcing compliance by third parties to
195
+ this License.
196
+
197
+ 7. If, as a consequence of a court judgment or allegation of patent
198
+ infringement or for any other reason (not limited to patent issues),
199
+ conditions are imposed on you (whether by court order, agreement or
200
+ otherwise) that contradict the conditions of this License, they do not
201
+ excuse you from the conditions of this License. If you cannot
202
+ distribute so as to satisfy simultaneously your obligations under this
203
+ License and any other pertinent obligations, then as a consequence you
204
+ may not distribute the Program at all. For example, if a patent
205
+ license would not permit royalty-free redistribution of the Program by
206
+ all those who receive copies directly or indirectly through you, then
207
+ the only way you could satisfy both it and this License would be to
208
+ refrain entirely from distribution of the Program.
209
+
210
+ If any portion of this section is held invalid or unenforceable under
211
+ any particular circumstance, the balance of the section is intended to
212
+ apply and the section as a whole is intended to apply in other
213
+ circumstances.
214
+
215
+ It is not the purpose of this section to induce you to infringe any
216
+ patents or other property right claims or to contest validity of any
217
+ such claims; this section has the sole purpose of protecting the
218
+ integrity of the free software distribution system, which is
219
+ implemented by public license practices. Many people have made
220
+ generous contributions to the wide range of software distributed
221
+ through that system in reliance on consistent application of that
222
+ system; it is up to the author/donor to decide if he or she is willing
223
+ to distribute software through any other system and a licensee cannot
224
+ impose that choice.
225
+
226
+ This section is intended to make thoroughly clear what is believed to
227
+ be a consequence of the rest of this License.
228
+
229
+ 8. If the distribution and/or use of the Program is restricted in
230
+ certain countries either by patents or by copyrighted interfaces, the
231
+ original copyright holder who places the Program under this License
232
+ may add an explicit geographical distribution limitation excluding
233
+ those countries, so that distribution is permitted only in or among
234
+ countries not thus excluded. In such case, this License incorporates
235
+ the limitation as if written in the body of this License.
236
+
237
+ 9. The Free Software Foundation may publish revised and/or new versions
238
+ of the General Public License from time to time. Such new versions will
239
+ be similar in spirit to the present version, but may differ in detail to
240
+ address new problems or concerns.
241
+
242
+ Each version is given a distinguishing version number. If the Program
243
+ specifies a version number of this License which applies to it and "any
244
+ later version", you have the option of following the terms and conditions
245
+ either of that version or of any later version published by the Free
246
+ Software Foundation. If the Program does not specify a version number of
247
+ this License, you may choose any version ever published by the Free Software
248
+ Foundation.
249
+
250
+ 10. If you wish to incorporate parts of the Program into other free
251
+ programs whose distribution conditions are different, write to the author
252
+ to ask for permission. For software which is copyrighted by the Free
253
+ Software Foundation, write to the Free Software Foundation; we sometimes
254
+ make exceptions for this. Our decision will be guided by the two goals
255
+ of preserving the free status of all derivatives of our free software and
256
+ of promoting the sharing and reuse of software generally.
257
+
258
+ NO WARRANTY
259
+
260
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+ REPAIR OR CORRECTION.
269
+
270
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+ POSSIBILITY OF SUCH DAMAGES.
279
+
280
+ END OF TERMS AND CONDITIONS
281
+
282
+ How to Apply These Terms to Your New Programs
283
+
284
+ If you develop a new program, and you want it to be of the greatest
285
+ possible use to the public, the best way to achieve this is to make it
286
+ free software which everyone can redistribute and change under these terms.
287
+
288
+ To do so, attach the following notices to the program. It is safest
289
+ to attach them to the start of each source file to most effectively
290
+ convey the exclusion of warranty; and each file should have at least
291
+ the "copyright" line and a pointer to where the full notice is found.
292
+
293
+ <one line to give the program's name and a brief idea of what it does.>
294
+ Copyright (C) <year> <name of author>
295
+
296
+ This program is free software; you can redistribute it and/or modify
297
+ it under the terms of the GNU General Public License as published by
298
+ the Free Software Foundation; either version 2 of the License, or
299
+ (at your option) any later version.
300
+
301
+ This program is distributed in the hope that it will be useful,
302
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
303
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304
+ GNU General Public License for more details.
305
+
306
+ You should have received a copy of the GNU General Public License along
307
+ with this program; if not, write to the Free Software Foundation, Inc.,
308
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309
+
310
+ Also add information on how to contact you by electronic and paper mail.
311
+
312
+ If the program is interactive, make it output a short notice like this
313
+ when it starts in an interactive mode:
314
+
315
+ Gnomovision version 69, Copyright (C) year name of author
316
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317
+ This is free software, and you are welcome to redistribute it
318
+ under certain conditions; type `show c' for details.
319
+
320
+ The hypothetical commands `show w' and `show c' should show the appropriate
321
+ parts of the General Public License. Of course, the commands you use may
322
+ be called something other than `show w' and `show c'; they could even be
323
+ mouse-clicks or menu items--whatever suits your program.
324
+
325
+ You should also get your employer (if you work as a programmer) or your
326
+ school, if any, to sign a "copyright disclaimer" for the program, if
327
+ necessary. Here is a sample; alter the names:
328
+
329
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
331
+
332
+ <signature of Ty Coon>, 1 April 1989
333
+ Ty Coon, President of Vice
334
+
335
+ This General Public License does not permit incorporating your program into
336
+ proprietary programs. If your program is a subroutine library, you may
337
+ consider it more useful to permit linking proprietary applications with the
338
+ library. If this is what you want to do, use the GNU Lesser General
339
+ Public License instead of this License.
aq_resizer.php ADDED
@@ -0,0 +1,250 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Title : Aqua Resizer
5
+ * Description : Resizes WordPress images on the fly
6
+ * Version : 1.2.1
7
+ * Author : Syamil MJ
8
+ * Author URI : http://aquagraphite.com
9
+ * License : WTFPL - http://sam.zoy.org/wtfpl/
10
+ * Documentation : https://github.com/sy4mil/Aqua-Resizer/
11
+ *
12
+ * @param string $url - (required) must be uploaded using wp media uploader
13
+ * @param int $width - (required)
14
+ * @param int $height - (optional)
15
+ * @param bool $crop - (optional) default to soft crop
16
+ * @param bool $single - (optional) returns an array if false
17
+ * @param bool $upscale - (optional) resizes smaller images
18
+ * @uses wp_upload_dir()
19
+ * @uses image_resize_dimensions()
20
+ * @uses wp_get_image_editor()
21
+ *
22
+ * @return str|array
23
+ */
24
+
25
+ if(!class_exists('Aq_Resize')) {
26
+ class Aq_Exception extends Exception {}
27
+
28
+ class Aq_Resize
29
+ {
30
+ /**
31
+ * The singleton instance
32
+ */
33
+ static private $instance = null;
34
+
35
+ /**
36
+ * Should an Aq_Exception be thrown on error?
37
+ * If false (default), then the error will just be logged.
38
+ */
39
+ public $throwOnError = false;
40
+
41
+ /**
42
+ * No initialization allowed
43
+ */
44
+ private function __construct() {}
45
+
46
+ /**
47
+ * No cloning allowed
48
+ */
49
+ private function __clone() {}
50
+
51
+ /**
52
+ * For your custom default usage you may want to initialize an Aq_Resize object by yourself and then have own defaults
53
+ */
54
+ static public function getInstance() {
55
+ if(self::$instance == null) {
56
+ self::$instance = new self;
57
+ }
58
+
59
+ return self::$instance;
60
+ }
61
+
62
+ /**
63
+ * Run, forest.
64
+ */
65
+ public function process( $url, $width = null, $height = null, $crop = null, $single = true, $upscale = false ) {
66
+ try {
67
+ // Validate inputs.
68
+ if (!$url)
69
+ throw new Aq_Exception('$url parameter is required');
70
+ if (!$width)
71
+ throw new Aq_Exception('$width parameter is required');
72
+ if (!$height)
73
+ throw new Aq_Exception('$height parameter is required');
74
+
75
+ // Caipt'n, ready to hook.
76
+ if ( true === $upscale ) add_filter( 'image_resize_dimensions', array($this, 'aq_upscale'), 10, 6 );
77
+
78
+ // Define upload path & dir.
79
+ $upload_info = wp_upload_dir();
80
+ $upload_dir = $upload_info['basedir'];
81
+ $upload_url = $upload_info['baseurl'];
82
+
83
+ $http_prefix = "http://";
84
+ $https_prefix = "https://";
85
+ $relative_prefix = "//"; // The protocol-relative URL
86
+
87
+ /* if the $url scheme differs from $upload_url scheme, make them match
88
+ if the schemes differe, images don't show up. */
89
+ if(!strncmp($url,$https_prefix,strlen($https_prefix))){ //if url begins with https:// make $upload_url begin with https:// as well
90
+ $upload_url = str_replace($http_prefix,$https_prefix,$upload_url);
91
+ }
92
+ elseif(!strncmp($url,$http_prefix,strlen($http_prefix))){ //if url begins with http:// make $upload_url begin with http:// as well
93
+ $upload_url = str_replace($https_prefix,$http_prefix,$upload_url);
94
+ }
95
+ elseif(!strncmp($url,$relative_prefix,strlen($relative_prefix))){ //if url begins with // make $upload_url begin with // as well
96
+ $upload_url = str_replace(array( 0 => "$http_prefix", 1 => "$https_prefix"),$relative_prefix,$upload_url);
97
+ }
98
+
99
+
100
+ // Check if $img_url is local.
101
+ if ( false === strpos( $url, $upload_url ) )
102
+ throw new Aq_Exception('Image must be local: ' . $url);
103
+
104
+ // Define path of image.
105
+ $rel_path = str_replace( $upload_url, '', $url );
106
+ $img_path = $upload_dir . $rel_path;
107
+
108
+ // Check if img path exists, and is an image indeed.
109
+ if ( ! file_exists( $img_path ) or ! getimagesize( $img_path ) )
110
+ throw new Aq_Exception('Image file does not exist (or is not an image): ' . $img_path);
111
+
112
+ // Get image info.
113
+ $info = pathinfo( $img_path );
114
+ $ext = $info['extension'];
115
+ list( $orig_w, $orig_h ) = getimagesize( $img_path );
116
+
117
+ // Get image size after cropping.
118
+ $dims = image_resize_dimensions( $orig_w, $orig_h, $width, $height, $crop );
119
+ $dst_w = $dims[4];
120
+ $dst_h = $dims[5];
121
+
122
+ // Return the original image only if it exactly fits the needed measures.
123
+ if ( ! $dims && ( ( ( null === $height && $orig_w == $width ) xor ( null === $width && $orig_h == $height ) ) xor ( $height == $orig_h && $width == $orig_w ) ) ) {
124
+ $img_url = $url;
125
+ $dst_w = $orig_w;
126
+ $dst_h = $orig_h;
127
+ } else {
128
+ // Use this to check if cropped image already exists, so we can return that instead.
129
+ $suffix = "{$dst_w}x{$dst_h}";
130
+ $dst_rel_path = str_replace( '.' . $ext, '', $rel_path );
131
+ $destfilename = "{$upload_dir}{$dst_rel_path}-{$suffix}.{$ext}";
132
+
133
+ if ( ! $dims || ( true == $crop && false == $upscale && ( $dst_w < $width || $dst_h < $height ) ) ) {
134
+ // Can't resize, so return false saying that the action to do could not be processed as planned.
135
+ throw new Aq_Exception('Unable to resize image because image_resize_dimensions() failed');
136
+ }
137
+ // Else check if cache exists.
138
+ elseif ( file_exists( $destfilename ) && getimagesize( $destfilename ) ) {
139
+ $img_url = "{$upload_url}{$dst_rel_path}-{$suffix}.{$ext}";
140
+ }
141
+ // Else, we resize the image and return the new resized image url.
142
+ else {
143
+
144
+ $editor = wp_get_image_editor( $img_path );
145
+
146
+ if ( is_wp_error( $editor ) || is_wp_error( $editor->resize( $width, $height, $crop ) ) ) {
147
+ throw new Aq_Exception('Unable to get WP_Image_Editor: ' .
148
+ $editor->get_error_message() . ' (is GD or ImageMagick installed?)');
149
+ }
150
+
151
+ $resized_file = $editor->save();
152
+
153
+ if ( ! is_wp_error( $resized_file ) ) {
154
+ $resized_rel_path = str_replace( $upload_dir, '', $resized_file['path'] );
155
+ $img_url = $upload_url . $resized_rel_path;
156
+ } else {
157
+ throw new Aq_Exception('Unable to save resized image file: ' . $editor->get_error_message());
158
+ }
159
+
160
+ }
161
+ }
162
+
163
+ // Okay, leave the ship.
164
+ if ( true === $upscale ) remove_filter( 'image_resize_dimensions', array( $this, 'aq_upscale' ) );
165
+
166
+ // Return the output.
167
+ if ( $single ) {
168
+ // str return.
169
+ $image = $img_url;
170
+ } else {
171
+ // array return.
172
+ $image = array (
173
+ 0 => $img_url,
174
+ 1 => $dst_w,
175
+ 2 => $dst_h
176
+ );
177
+ }
178
+
179
+ return $image;
180
+ }
181
+ catch (Aq_Exception $ex) {
182
+ error_log('Aq_Resize.process() error: ' . $ex->getMessage());
183
+
184
+ if ($this->throwOnError) {
185
+ // Bubble up exception.
186
+ throw $ex;
187
+ }
188
+ else {
189
+ // Return false, so that this patch is backwards-compatible.
190
+ return false;
191
+ }
192
+ }
193
+ }
194
+
195
+ /**
196
+ * Callback to overwrite WP computing of thumbnail measures
197
+ */
198
+ function aq_upscale( $default, $orig_w, $orig_h, $dest_w, $dest_h, $crop ) {
199
+ if ( ! $crop ) return null; // Let the wordpress default function handle this.
200
+
201
+ // Here is the point we allow to use larger image size than the original one.
202
+ $aspect_ratio = $orig_w / $orig_h;
203
+ $new_w = $dest_w;
204
+ $new_h = $dest_h;
205
+
206
+ if ( ! $new_w ) {
207
+ $new_w = intval( $new_h * $aspect_ratio );
208
+ }
209
+
210
+ if ( ! $new_h ) {
211
+ $new_h = intval( $new_w / $aspect_ratio );
212
+ }
213
+
214
+ $size_ratio = max( $new_w / $orig_w, $new_h / $orig_h );
215
+
216
+ $crop_w = round( $new_w / $size_ratio );
217
+ $crop_h = round( $new_h / $size_ratio );
218
+
219
+ $s_x = floor( ( $orig_w - $crop_w ) / 2 );
220
+ $s_y = floor( ( $orig_h - $crop_h ) / 2 );
221
+
222
+ return array( 0, 0, (int) $s_x, (int) $s_y, (int) $new_w, (int) $new_h, (int) $crop_w, (int) $crop_h );
223
+ }
224
+ }
225
+ }
226
+
227
+
228
+
229
+
230
+
231
+ if(!function_exists('aq_resize')) {
232
+
233
+ /**
234
+ * This is just a tiny wrapper function for the class above so that there is no
235
+ * need to change any code in your own WP themes. Usage is still the same :)
236
+ */
237
+ function aq_resize( $url, $width = null, $height = null, $crop = null, $single = true, $upscale = false ) {
238
+ /* WPML Fix */
239
+ if ( defined( 'ICL_SITEPRESS_VERSION' ) ){
240
+ global $sitepress;
241
+ $url = $sitepress->convert_url( $url, $sitepress->get_default_language() );
242
+ }
243
+ /* WPML Fix */
244
+
245
+ $aq_resize = Aq_Resize::getInstance();
246
+ return $aq_resize->process( $url, $width, $height, $crop, $single, $upscale );
247
+ }
248
+ }
249
+
250
+
assets/css/input.css ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .acf-photo-gallery-metabox-list li {
2
+ display: inline-table;
3
+ padding: 3px;
4
+ border: 1px solid #ccc;
5
+ margin: 8px;
6
+ position: relative;
7
+ vertical-align: top;
8
+ width: 202px;
9
+ height: 202px;
10
+ }
11
+
12
+ .acf-photo-gallery-metabox-list li img {
13
+ width: 100%;
14
+ }
15
+
16
+ .acf-photo-gallery-metabox-list .acf-photo-gallery-media-box-placeholder {
17
+ width: 150px;
18
+ height: 150px;
19
+ border: 1px dashed #ccc;
20
+ }
21
+
22
+ .acf-photo-gallery-metabox-list .acf-photo-gallery-media-box-placeholder .dashicons-format-image {
23
+ font-size: 150px;
24
+ color: #ccc;
25
+ }
26
+
27
+ .acf-photo-gallery-metabox-list li .dashicons-dismiss {
28
+ position: absolute;
29
+ top: -9px;
30
+ right: -9px;
31
+ color: #fff;
32
+ background: #000000;
33
+ border-radius: 50%;
34
+ }
35
+
36
+ .acf-photo-gallery-metabox-list li .dashicons-edit {
37
+ position: absolute;
38
+ top: -9px;
39
+ right: 12px;
40
+ color: #fff;
41
+ background: #000000;
42
+ border-radius: 50%;
43
+ }
44
+
45
+ #acf-photo-gallery-metabox-edit .acf-edit-photo-gallery {
46
+ display: none;
47
+ background: #F3F3F3;
48
+ border: 2px solid #ccc;
49
+ width: 308px;
50
+ position: absolute;
51
+ top: 0px;
52
+ right: 0;
53
+ z-index: 9999;
54
+ padding: 15px;
55
+ }
56
+
57
+ #acf-photo-gallery-metabox-edit .acf-edit-photo-gallery .save-changes-wrap {
58
+ margin-top: 15px;
59
+ }
60
+
61
+ #acf-photo-gallery-metabox-edit .acf-edit-photo-gallery label {
62
+ margin-top: 10px;
63
+ display: block;
64
+ }
65
+
66
+ #acf-photo-gallery-metabox-edit .acf-edit-photo-gallery textarea {
67
+ min-height: 100px
68
+ }
69
+
70
+ .acf-photo-gallery-metabox-list li.acf-photo-gallery-sortable-placeholder {
71
+ border: 1px dashed #ccc;
72
+ width: 150px;
73
+ height: 150px;
74
+ display: inline-block;
75
+ }
assets/index.php ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ // Silence is golden.
assets/js/input.js ADDED
@@ -0,0 +1,196 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function($) {
2
+
3
+ function initialize_field($el) {
4
+ //$el.doStuff();
5
+ }
6
+
7
+ $(document).ready(function() {
8
+ $(".acf-photo-gallery-metabox-list").sortable({
9
+ containment: "parent",
10
+ placeholder: "acf-photo-gallery-sortable-placeholder",
11
+ tolerance: 'pointer'
12
+ }).disableSelection();
13
+ });
14
+
15
+ /*function acf_photo_gallery_limit_images( $el ){
16
+ var field = $el.context.id;
17
+ $(document).on('click', '.attachments-browser ul.attachments li.attachment', function(){
18
+ var max = $('#' + field + ' input[name="acf-photo-gallery-field-max"]').val();
19
+ var selCount = $('#' + field + ' .acf-photo-gallery-metabox-list li').length;
20
+ var count = $('.attachments-browser ul.attachments li.attachment[aria-checked=true]').length;
21
+ var finalCount = selCount + +count;
22
+ if( finalCount > max ){
23
+ alert('You are only allowed to select maximum of ' + max + ' images.');
24
+ $(this).attr('aria-checked', false).removeClass('selected details');
25
+ return false;
26
+ }
27
+ });
28
+ }*/
29
+
30
+ function acf_photo_gallery_edit(id, url, title, caption) {
31
+ var html;
32
+ html = '<div id="acf-photo-gallery-metabox-edit-' + id + '" class="acf-edit-photo-gallery">';
33
+ html += '<h3>Edit Image</h3>';
34
+ html += '<label>URL</label><input type="text" value="' + url + '"/>';
35
+ html += '<label><input type="checkbox" value="1"/>Open in new tab</label>';
36
+ html += '<label>Title</label><input type="text" value="' + title + '"/>';
37
+ html += '<label>Caption</label><textarea>' + caption + '</textarea>';
38
+ html += '<button class="button button-primary button-large" type="button">Save Changes</button>';
39
+ html += '<button class="button button-large button-close" type="button" data-close="' + id + '">Close</button>';
40
+ html += '</div>';
41
+ return html;
42
+ }
43
+
44
+ function acf_photo_gallery_html(attachment, field) {
45
+ var html, id, url, title, caption;
46
+ id = attachment.id;
47
+ url = attachment.url;
48
+ title = attachment.title;
49
+ caption = attachment.caption;
50
+
51
+ if (typeof attachment.sizes.thumbnail != 'undefined') {
52
+ url = attachment.sizes.thumbnail.url
53
+ }
54
+
55
+ html = acf_photo_gallery_edit(id, url, title, caption);
56
+ $('#acf-' + field + ' .acf-photo-gallery-metabox-edit').append(html);
57
+ $('#acf-' + field + ' .acf-photo-gallery-metabox-list').prepend('<li id="acf-photo-gallery-mediabox-' + id + '" data-id="' + id + '"><a class="dashicons dashicons-edit" href="#" title="Edit" data-id="' + id + '"></a><a class="dashicons dashicons-dismiss" href="#" data-id="' + id + '" data-field="' + field + '" title="Remove this photo from the gallery"></a><input type="hidden" name="' + field + '[]" value="' + id + '"/><img src="' + url + '"/></li>');
58
+ }
59
+
60
+ function acf_photo_gallery_add_media($el) {
61
+ var acf_photo_gallery_ids = new Array();
62
+ if ($('#acf-photo-gallery-metabox-add-images').length > 0) {
63
+ if (typeof wp !== 'undefined' && wp.media && wp.media.editor) {
64
+ $('.wrap').on('click', '#acf-photo-gallery-metabox-add-images', function(e) {
65
+ e.preventDefault();
66
+ var button = $(this);
67
+ var id = button.prev();
68
+ var field = button.attr('data-id');
69
+
70
+ var pre_selected_list = $('#acf-' + field + ' .acf-photo-gallery-metabox-list li');
71
+ var pre_selected = pre_selected_list.length;
72
+
73
+ wp.media.editor.send.attachment = function(props, attachment){
74
+ acf_photo_gallery_html(attachment, field);
75
+ };
76
+
77
+ wp.media.editor.open( button, function(){} );
78
+ if ($('#acf-' + field + ' .acf-photo-gallery-metabox-list li.acf-photo-gallery-media-box-placeholder').length > 0) {
79
+ $('#acf-' + field + ' .acf-photo-gallery-metabox-list li.acf-photo-gallery-media-box-placeholder').remove();
80
+ }
81
+
82
+ /*if( pre_selected > 0 ){
83
+ pre_selected_list.each(function( key, item ){
84
+ var pre_selected_id = $(this).attr('data-id');
85
+ //$('.attachments-browser ul.attachments li[data-id=' + pre_selected_id + ']').attr('aria-checked', true).addClass('details selected');
86
+ console.log( $('.attachments-browser ul.attachments li[data-id=269]').attr('class') );
87
+ $('.attachments-browser ul.attachments li[data-id="' + pre_selected_id + '"]').attr('aria-checked', true);
88
+ });
89
+ }*/
90
+
91
+ return false;
92
+ });
93
+ }
94
+ };
95
+ }
96
+
97
+ $(document).on('click', '.acf-photo-gallery-metabox-list .dashicons-dismiss', function() {
98
+ var url = $(this).attr('href');
99
+ var id = $(this).attr('data-id');
100
+ var field = $(this).attr('data-field');
101
+ if (confirm('You are about to remove this photo from the gallery. Are you sure?')) {
102
+ $.get(url, function(data) {
103
+ $('#acf-' + field + ' #acf-photo-gallery-mediabox-' + id).fadeOut('fast').remove();
104
+ if ($('#acf-' + field + ' .acf-photo-gallery-metabox-list li').length < 1) {
105
+ $('#acf-' + field + ' .acf-photo-gallery-metabox-list').append('<li class="acf-photo-gallery-media-box-placeholder"><span class="dashicons dashicons-format-image"></span></li>');
106
+ }
107
+ });
108
+ }
109
+ return false;
110
+ });
111
+
112
+ $(document).on('click', '#acf-photo-gallery-metabox-edit .acf-edit-photo-gallery button.button-close', function() {
113
+ var id;
114
+ id = $(this).attr('data-close');
115
+ $('#acf-photo-gallery-metabox-edit #acf-photo-gallery-metabox-edit-' + id).fadeOut('fast');
116
+ return false;
117
+ });
118
+
119
+ $(document).on('click', '#acf-photo-gallery-metabox-edit .acf-edit-photo-gallery button.button-primary', function() {
120
+ var button, field, data, post, attachment, action, nonce, form = {};
121
+ action = 'acf_photo_gallery_edit_save';
122
+ attachment = $(this).attr('data-id');
123
+
124
+ $('#acf-photo-gallery-metabox-edit-' + attachment + ' .acf-photo-gallery-edit-field').each(function(i, obj) {
125
+ if (obj.name == 'acf-pg-hidden-action') {
126
+ form['action'] = obj.value;
127
+ } else {
128
+ form[obj.name] = obj.value;
129
+ }
130
+ });
131
+
132
+ button = $(this);
133
+ button.attr('disabled', true).html('Saving...');
134
+ $.post(acf.ajaxurl, form, function(data) {
135
+ button.attr('disabled', false).html('Save Changes');
136
+ $('#acf-photo-gallery-metabox-edit #acf-photo-gallery-metabox-edit-' + attachment).fadeOut('fast');
137
+ });
138
+ return false;
139
+ });
140
+
141
+ $(document).on('click', '.acf-photo-gallery-metabox-list .dashicons-edit', function() {
142
+ var id, field;
143
+ id = $(this).attr('data-id');
144
+ field = $(this).attr('data-field');
145
+ $('#acf-' + field + ' #acf-photo-gallery-metabox-edit-' + id).fadeToggle('fast');
146
+ return false;
147
+ });
148
+
149
+ if (typeof acf.add_action !== 'undefined') {
150
+ /*
151
+ * ready append (ACF5)
152
+ *
153
+ * These are 2 events which are fired during the page load
154
+ * ready = on page load similar to $(document).ready()
155
+ * append = on new DOM elements appended via repeater field
156
+ *
157
+ * @type event
158
+ * @date 20/07/13
159
+ *
160
+ * @param $el (jQuery selection) the jQuery element which contains the ACF fields
161
+ * @return n/a
162
+ */
163
+ acf.add_action('ready append', function($el) {
164
+ // search $el for fields of type 'photo_gallery'
165
+ acf.get_fields({ type: 'photo_gallery' }, $el).each(function() {
166
+ initialize_field($(this));
167
+ acf_photo_gallery_add_media( $(this) );
168
+ //acf_photo_gallery_edit_popover( $(this) );
169
+ //acf_photo_gallery_limit_images( $(this) );
170
+ });
171
+ });
172
+ } else {
173
+ /*
174
+ * acf/setup_fields (ACF4)
175
+ *
176
+ * This event is triggered when ACF adds any new elements to the DOM.
177
+ *
178
+ * @type function
179
+ * @since 1.0.0
180
+ * @date 01/01/12
181
+ *
182
+ * @param event e: an event object. This can be ignored
183
+ * @param Element postbox: An element which contains the new HTML
184
+ *
185
+ * @return n/a
186
+ */
187
+ $(document).on('acf/setup_fields', function(e, postbox) {
188
+ $(postbox).find('.field[data-field_type="photo_gallery"]').each(function() {
189
+ initialize_field($(this));
190
+ acf_photo_gallery_add_media( $(this) );
191
+ //acf_photo_gallery_edit_popover( $(this) );
192
+ //acf_photo_gallery_limit_images( $(this) );
193
+ });
194
+ });
195
+ }
196
+ })(jQuery);
fields/acf-photo_gallery-v4.php ADDED
@@ -0,0 +1,341 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // exit if accessed directly
4
+ if( ! defined( 'ABSPATH' ) ) exit;
5
+
6
+ //Saving the gallery image ids into the database postmeta table in the same order.
7
+ function acf_photo_gallery_save( $post_id ){
8
+ // If this is a revision, get real post ID
9
+ if ( $parent_id = wp_is_post_revision( $post_id ) )
10
+ $post_id = $parent_id;
11
+ // unhook this function so it doesn't loop infinitely
12
+ remove_action( 'save_post', 'acf_photo_gallery_save' );
13
+
14
+ $field = isset($_POST['acf-photo-gallery-field-id'])? $_POST['acf-photo-gallery-field-id']: null;
15
+ if( $field && count($field) ){ //This fix php error when the field is null. Thanks to @JulienRobitaille on Github for the fix
16
+ foreach($field as $k => $v ){
17
+ $field_id = isset($_POST['acf-photo-gallery-field-id'][$k])? $_POST['acf-photo-gallery-field-id'][$k]: null;
18
+ if( !empty($field_id) ){
19
+ $ids = !empty($field) && isset($_POST[$field_id])? $_POST[$field_id]: null;
20
+ if( !empty($ids) ){
21
+ $ids = implode(',', $ids);
22
+ update_post_meta( $post_id, $field_id, $ids );
23
+ }
24
+ }
25
+ }
26
+ }
27
+ // re-hook this function
28
+ add_action( 'save_post', 'acf_photo_gallery_save' );
29
+ }
30
+ add_action( 'save_post', 'acf_photo_gallery_save' );
31
+
32
+ //Remove photo from the database array
33
+ function acf_photo_gallery_remove_photo(){
34
+ if( wp_verify_nonce( $_GET['_wpnonce'], 'nonce_acf_photo_gallery') and !empty($_GET['post']) and !empty($_GET['photo']) and !empty($_GET['field']) ){
35
+ $field = $_GET['field'];
36
+ $post = $_GET['post'];
37
+ $photo = $_GET['photo'];
38
+ $photo = preg_replace('/\D/', '', $photo);
39
+ $id = str_replace('acf-field-', '', $_GET['id']);
40
+ $meta = get_post_meta($post, $id, true);
41
+ $meta_arr = explode(',', $meta);
42
+ if( in_array($photo, $meta_arr) ){
43
+ foreach($meta_arr as $key => $value){
44
+ if( $photo == $value ){
45
+ unset($meta_arr[$key]);
46
+ if( count($meta_arr) > 0 ){
47
+ $meta_arr = implode(',', $meta_arr);
48
+ update_post_meta( $post, $id, $meta_arr );
49
+ } else {
50
+ delete_post_meta( $post, $id );
51
+ }
52
+ }
53
+ }
54
+ }
55
+ }
56
+ die();
57
+ }
58
+ add_action( 'wp_ajax_nopriv_acf_photo_gallery_remove_photo', 'acf_photo_gallery_remove_photo' );
59
+ add_action( 'wp_ajax_acf_photo_gallery_remove_photo', 'acf_photo_gallery_remove_photo' );
60
+
61
+ //Editing and saving photo details
62
+ function acf_photo_gallery_edit_save(){
63
+
64
+ if( wp_verify_nonce( $_POST['acf-pg-hidden-nonce'], 'acf_photo_gallery_edit_save') and !empty($_POST['acf-pg-hidden-field']) and !empty($_POST['acf-pg-hidden-post']) and !empty($_POST['acf-pg-hidden-attachment']) ){
65
+
66
+ $request = $_POST;
67
+
68
+ $field = sanitize_text_field($_POST['acf-pg-hidden-field']);
69
+ $post = sanitize_text_field($_POST['acf-pg-hidden-post']);
70
+ $attachment = sanitize_text_field($_POST['acf-pg-hidden-attachment']);
71
+ $title = sanitize_text_field($_POST['title']);
72
+ $caption = sanitize_text_field($_POST['caption']);
73
+
74
+ unset( $request['acf-pg-hidden-field'] );
75
+ unset( $request['acf-pg-hidden-post'] );
76
+ unset( $request['acf-pg-hidden-attachment'] );
77
+ unset( $request['action'] );
78
+ unset( $request['acf-pg-hidden-nonce'] );
79
+ unset( $request['title'] );
80
+ unset( $request['caption'] );
81
+
82
+ $acf_photo_gallery_editbox_caption_from_attachment = apply_filters( 'acf_photo_gallery_editbox_caption_from_attachment', $request);
83
+ if( $acf_photo_gallery_editbox_caption_from_attachment == 1 ){
84
+ $captionColumn = 'post_excerpt';
85
+ } else {
86
+ $captionColumn = 'post_content';
87
+ }
88
+
89
+ $post = array('ID' => $attachment, 'post_title' => $title, $captionColumn => $caption);
90
+ wp_update_post( $post );
91
+
92
+ foreach( $request as $name => $value ){
93
+ $name = sanitize_text_field( $name );
94
+ $value = sanitize_text_field( $value );
95
+ if( !empty($value) ){
96
+ update_post_meta( $attachment, $field . '_' . $name, $value);
97
+ } else {
98
+ delete_post_meta( $attachment, $field . '_' . $name);
99
+ }
100
+ }
101
+ }
102
+ die();
103
+ }
104
+ add_action( 'wp_ajax_nopriv_acf_photo_gallery_edit_save', 'acf_photo_gallery_edit_save' );
105
+ add_action( 'wp_ajax_acf_photo_gallery_edit_save', 'acf_photo_gallery_edit_save' );
106
+
107
+ //Metabox for the photo edit
108
+ function acf_photo_gallery_edit($field, $nonce, $attachment, $url = '', $title, $caption, $target = 0){
109
+ $args = array();
110
+ $args['url'] = $url;
111
+ $args['title'] = $title;
112
+ $args['caption'] = $caption;
113
+ $args['target'] = $target;
114
+ $filter_fields = apply_filters( 'acf_photo_gallery_image_fields', $args, $attachment, $field );
115
+ ?>
116
+ <div id="acf-photo-gallery-metabox-edit-<?php echo $attachment; ?>" class="acf-edit-photo-gallery">
117
+ <h3>Edit Image</h3>
118
+ <input class="acf-photo-gallery-edit-field" type="hidden" name="acf-pg-hidden-field" value="<?php echo $field; ?>"/>
119
+ <input class="acf-photo-gallery-edit-field" type="hidden" name="acf-pg-hidden-post" value="<?php echo $_GET['post']; ?>"/>
120
+ <input class="acf-photo-gallery-edit-field" type="hidden" name="acf-pg-hidden-attachment" value="<?php echo $attachment; ?>"/>
121
+ <input class="acf-photo-gallery-edit-field" type="hidden" name="acf-pg-hidden-action" value="acf_photo_gallery_edit_save"/>
122
+ <input class="acf-photo-gallery-edit-field" type="hidden" name="acf-pg-hidden-nonce" value="<?php echo $nonce; ?>"/>
123
+ <?php
124
+ foreach( $filter_fields as $key => $item ){
125
+ $type = ($item['type'])?$item['type']:null;
126
+ $label = $item['label']?$item['label']:null;
127
+ $name = $item['name']?$item['name']:null;
128
+ $value = $item['value']?$item['value']:null;
129
+ ?>
130
+ <?php if( $type == 'text' ){ ?>
131
+ <label><?php echo $label; ?></label><input class="acf-photo-gallery-edit-field" type="<?php echo $type; ?>" name="<?php echo $name; ?>" value="<?php echo $value; ?>"/>
132
+ <?php } else if( $type == 'checkbox' ){ ?>
133
+ <label><input class="acf-photo-gallery-edit-field" type="checkbox" name="target" value="<?php echo $value; ?>" <?php if( $target == 'true' ){?> checked<?php } ?>/><?php echo $label; ?></label>
134
+ <?php } else if( $type == 'textarea' ){ ?>
135
+ <label><?php echo $label; ?></label><textarea class="acf-photo-gallery-edit-field" name="<?php echo $name; ?>"><?php echo $value; ?></textarea>
136
+ <?php } ?>
137
+ <?php } ?>
138
+ <div class="save-changes-wrap">
139
+ <button class="button button-primary button-large" type="submit" data-id="<?php echo $attachment; ?>">Save Changes</button>
140
+ <button class="button button-large button-close" type="button" data-close="<?php echo $attachment; ?>">Close</button>
141
+ </div>
142
+ </div>
143
+ <?php }
144
+
145
+ // check if class already exists
146
+ if( !class_exists('acf_field_photo_gallery') ) :
147
+
148
+ class acf_field_photo_gallery extends acf_field {
149
+
150
+ // vars
151
+ var $settings, // will hold info such as dir / path
152
+ $defaults; // will hold default field options
153
+
154
+
155
+ /*
156
+ * __construct
157
+ *
158
+ * Set name / label needed for actions / filters
159
+ *
160
+ * @since 3.6
161
+ * @date 23/01/13
162
+ */
163
+
164
+ function __construct( $settings )
165
+ {
166
+ // vars
167
+ $this->name = 'photo_gallery';
168
+ $this->label = __('Photo Gallery');
169
+ $this->category = __("Content",'acf'); // Basic, Content, Choice, etc
170
+ $this->defaults = array(
171
+ // add default here to merge into your field.
172
+ // This makes life easy when creating the field options as you don't need to use any if( isset('') ) logic. eg:
173
+ //'preview_size' => 'thumbnail'
174
+ );
175
+
176
+
177
+ // do not delete!
178
+ parent::__construct();
179
+
180
+
181
+ // settings
182
+ $this->settings = $settings;
183
+
184
+ }
185
+
186
+
187
+ /*
188
+ * create_options()
189
+ *
190
+ * Create extra options for your field. This is rendered when editing a field.
191
+ * The value of $field['name'] can be used (like below) to save extra data to the $field
192
+ *
193
+ * @type action
194
+ * @since 3.6
195
+ * @date 23/01/13
196
+ *
197
+ * @param $field - an array holding all the field's data
198
+ */
199
+
200
+ function test_create_options( $field ){
201
+ // defaults?
202
+ /*
203
+ $field = array_merge($this->defaults, $field);
204
+ */
205
+
206
+ // key is needed in the field names to correctly save the data
207
+ $key = $field['name'];
208
+
209
+ // Create Field Options HTML
210
+ ?>
211
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
212
+ <td class="label">
213
+ <label><?php _e("Max",'acf'); ?></label>
214
+ <p class="description"><?php _e("Leave it empty for no limit",'acf'); ?></p>
215
+ </td>
216
+ <td>
217
+ <?php
218
+ do_action('acf/create_field', array(
219
+ 'type' => 'number',
220
+ 'name' => 'fields['.$key.'][max]',
221
+ 'value' => !empty($field['max'])? preg_replace('/\D/', '', $field['max']):'',
222
+ 'layout' => 'horizontal'
223
+ ));
224
+ ?>
225
+ </td>
226
+ </tr>
227
+ <?php }
228
+
229
+ /*
230
+ * create_field()
231
+ *
232
+ * Create the HTML interface for your field
233
+ *
234
+ * @param $field - an array holding all the field's data
235
+ *
236
+ * @type action
237
+ * @since 3.6
238
+ * @date 23/01/13
239
+ */
240
+
241
+ function create_field( $field )
242
+ {
243
+ // create Field HTML
244
+ global $post;
245
+ $nonce_acf_photo_gallery = wp_create_nonce( 'nonce_acf_photo_gallery' );
246
+ $_name = get_post_meta($post->ID, str_replace('acf-field-', '', $field['id']), true );
247
+ ?>
248
+ <div id="acf-photo-gallery-metabox">
249
+ <input type="hidden" name="acf-photo-gallery-field" value="<?php echo $field['key']; ?>"/>
250
+ <input type="hidden" name="acf-photo-gallery-field-id[]" value="<?php echo str_replace('acf-field-', '', $field['id']); ?>"/>
251
+ <!---<input type="hidden" name="acf-photo-gallery-field-max" value="<?php //echo $field['max']; ?>"/>-->
252
+ <div id="acf-photo-gallery-metabox-edit">
253
+ <?php
254
+ if( $_name ):
255
+ $acf_photo_gallery_editbox_caption_from_attachment = apply_filters( 'acf_photo_gallery_editbox_caption_from_attachment', $field);
256
+ $acf_photo_gallery_attachments = $_name;
257
+ $acf_photo_gallery_attachments = explode(',', $acf_photo_gallery_attachments);
258
+ $args = array( 'post_type' => 'attachment', 'posts_per_page' => -1, 'post__in' => $acf_photo_gallery_attachments );
259
+ $acf_photo_gallery_attachments = get_posts( $args );
260
+ $nonce = wp_create_nonce('acf_photo_gallery_edit_save');
261
+ foreach($acf_photo_gallery_attachments as $attachment):
262
+ $id = $attachment->ID;
263
+ $url = get_post_meta($id, $field['_name'] . '_url', true);
264
+ $target = get_post_meta($id, $field['_name'] . '_target', true);
265
+ $title = $attachment->post_title;
266
+ if( $acf_photo_gallery_editbox_caption_from_attachment == 1 ){
267
+ $caption = wp_get_attachment_caption( $id );
268
+ } else {
269
+ $caption = $attachment->post_content;
270
+ }
271
+ acf_photo_gallery_edit($field['_name'], $nonce, $id, $url, $title, $caption, $target);
272
+ endforeach;
273
+ endif;
274
+ ?>
275
+ </div>
276
+ <ul id="acf-photo-gallery-metabox-list" class="acf-photo-gallery-metabox-list">
277
+ <?php
278
+ if( $_name ):
279
+ $acf_photo_gallery_attachments = $_name;
280
+ $acf_photo_gallery_attachments = explode(',', $acf_photo_gallery_attachments);
281
+ foreach($acf_photo_gallery_attachments as $image):
282
+ ?>
283
+ <li id="acf-photo-gallery-mediabox-<?php echo $image; ?>" data-id="<?php echo $image; ?>">
284
+ <a class="dashicons dashicons-edit" href="#" title="Edit" data-id="<?php echo $image; ?>" data-field="<?php echo $field['_name']; ?>"></a>
285
+ <a class="dashicons dashicons-dismiss" href="<?php echo admin_url('admin-ajax.php'); ?>?action=acf_photo_gallery_remove_photo&_wpnonce=<?php echo $nonce_acf_photo_gallery; ?>&post=<?php echo $post->ID; ?>&photo=<?php echo $image; ?>&field=<?php echo $field['key']; ?>&id=<?php echo $field['id']; ?>" data-id="<?php echo $image; ?>" data-field="<?php echo $field['_name']; ?>" title="Remove this photo from the gallery"></a>
286
+ <input type="hidden" name="<?php echo $field['_name']; ?>[]" value="<?php echo $image; ?>"/>
287
+ <img src="<?php echo wp_get_attachment_thumb_url( $image ); ?>"/>
288
+ </li>
289
+ <?php endforeach; else: ?><li class="acf-photo-gallery-media-box-placeholder"><span class="dashicons dashicons-format-image"></span></li><?php endif; ?>
290
+ </ul>
291
+ <button class="button button-primary button-large" id="acf-photo-gallery-metabox-add-images" type="button" data-id="<?php echo $field['_name']; ?>">Add Images</button>
292
+ </p>
293
+ </div>
294
+ <?php
295
+ }
296
+
297
+
298
+ /*
299
+ * input_admin_enqueue_scripts()
300
+ *
301
+ * This action is called in the admin_enqueue_scripts action on the edit screen where your field is created.
302
+ * Use this action to add CSS + JavaScript to assist your create_field() action.
303
+ *
304
+ * $info http://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts
305
+ * @type action
306
+ * @since 3.6
307
+ * @date 23/01/13
308
+ */
309
+
310
+ function input_admin_enqueue_scripts()
311
+ {
312
+ // Note: This function can be removed if not used
313
+
314
+
315
+ // vars
316
+ $url = $this->settings['url'];
317
+ $version = $this->settings['version'];
318
+
319
+
320
+ // register & include JS
321
+ wp_enqueue_script( 'jquery-ui-sortable' );
322
+ wp_register_script( 'acf-input-photo_gallery', "{$url}assets/js/input.js", array('acf-input'), $version );
323
+ wp_enqueue_script( 'acf-input-photo_gallery');
324
+
325
+ // register & include CSS
326
+ wp_register_style( 'acf-input-photo_gallery', "{$url}assets/css/input.css", array('acf-input'), $version );
327
+ wp_enqueue_style('acf-input-photo_gallery');
328
+
329
+ }
330
+
331
+ }
332
+
333
+
334
+ // initialize
335
+ new acf_field_photo_gallery( $this->settings );
336
+
337
+
338
+ // class_exists check
339
+ endif;
340
+
341
+ ?>
fields/index.php ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ // Silence is golden.
index.php ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ // Silence is golden.
lang/index.php ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ // Silence is golden.
navz-photo-gallery.php ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: ACF Photo Gallery Field
4
+ Plugin URI: http://www.navz.me/
5
+ Description: An extension for Advance Custom Fields which lets you add photo gallery functionality on your websites.
6
+ Version: 1.6.2
7
+ Author: Navneil Naicker
8
+ Author URI: http://www.navz.me/
9
+ License: GPLv2 or later
10
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
+ */
12
+
13
+ // exit if accessed directly
14
+ if( ! defined( 'ABSPATH' ) ) exit;
15
+
16
+
17
+ // check if class already exists
18
+ if( !class_exists('acf_plugin_photo_gallery') ) :
19
+
20
+ class acf_plugin_photo_gallery {
21
+
22
+ /*
23
+ * __construct
24
+ *
25
+ * This function will setup the class functionality
26
+ *
27
+ * @type function
28
+ * @date 17/02/2016
29
+ * @since 1.0.0
30
+ *
31
+ * @param n/a
32
+ * @return n/a
33
+ */
34
+
35
+ function __construct() {
36
+
37
+ // vars
38
+ $this->settings = array(
39
+ 'version' => '1.6.2',
40
+ 'url' => plugin_dir_url( __FILE__ ),
41
+ 'path' => plugin_dir_path( __FILE__ )
42
+ );
43
+
44
+
45
+ // set text domain
46
+ // https://codex.wordpress.org/Function_Reference/load_plugin_textdomain
47
+ load_plugin_textdomain( 'acf-photo_gallery', false, plugin_basename( dirname( __FILE__ ) ) . '/lang' );
48
+
49
+ add_action( 'admin_enqueue_scripts', array($this, 'acf_photo_gallery_sortable') );
50
+
51
+ // include field
52
+ add_action('acf/include_field_types', array($this, 'include_field_types')); // v5
53
+ add_action('acf/register_fields', array($this, 'include_field_types')); // v4
54
+
55
+ add_filter( 'acf_photo_gallery_caption_from_attachment', '__return_false' );
56
+
57
+ }
58
+
59
+ function acf_photo_gallery_sortable($hook) {
60
+ if ( 'post.php' == $hook ) {
61
+ wp_enqueue_script( 'jquery-ui-sortable', 'jquery-ui-sortable', 'jquery', '9999', true);
62
+ }
63
+ }
64
+
65
+ /*
66
+ * include_field_types
67
+ *
68
+ * This function will include the field type class
69
+ *
70
+ * @type function
71
+ * @date 17/02/2016
72
+ * @since 1.0.0
73
+ *
74
+ * @param $version (int) major ACF version. Defaults to false
75
+ * @return n/a
76
+ */
77
+
78
+ function include_field_types( $version = false ) {
79
+
80
+ // support empty $version
81
+ if( !$version ) $version = 4;
82
+
83
+
84
+ // include
85
+ include_once('fields/acf-photo_gallery-v' . $version . '.php');
86
+
87
+ }
88
+
89
+ }
90
+
91
+ // initialize
92
+ new acf_plugin_photo_gallery();
93
+
94
+ // class_exists check
95
+ endif;
96
+
97
+ //Helper function for pulling the images
98
+ function acf_photo_gallery($field = null, $post_id){
99
+ $images = get_post_meta($post_id, $field, true);
100
+ $images = explode(',', $images);
101
+ $args = array( 'post_type' => 'attachment', 'posts_per_page' => -1, 'post__in' => $images, 'orderby' => 'post__in' );
102
+ $images = get_posts( $args );
103
+ $images = array_filter($images);
104
+ $array = array();
105
+ if( count($images) ):
106
+ foreach($images as $image):
107
+ $title = $image->post_title;
108
+ $content = $image->post_content;
109
+ $full_url = wp_get_attachment_url($image->ID);
110
+ $thumbnail_url = wp_get_attachment_thumb_url($image->ID);
111
+ $meta_data = wp_get_attachment_metadata($image->ID);
112
+ $large_srcset = wp_get_attachment_image_srcset( $image->ID,'large', $meta_data);
113
+ $medium_srcset = wp_get_attachment_image_srcset( $image->ID,'medium', $meta_data);
114
+ $url = get_post_meta($image->ID, $field . '_url', true);
115
+ $target = get_post_meta($image->ID, $field . '_target', true);
116
+ $array[] = array(
117
+ 'id' => $image->ID,
118
+ 'title' => $title,
119
+ 'caption' => $content,
120
+ 'full_image_url' => $full_url,
121
+ 'thumbnail_image_url' => $thumbnail_url,
122
+ 'large_srcset' => $large_srcset,
123
+ 'medium_srcset' => $medium_srcset,
124
+ 'url' => $url,
125
+ 'target' => $target
126
+ );
127
+ endforeach;
128
+ endif;
129
+ return $array;
130
+ }
131
+
132
+ //Resizes the image
133
+ function acf_photo_gallery_resize_image( $img_url, $width = 150, $height = 150){
134
+ if( !function_exists('aq_resize') ){
135
+ require_once( dirname(__FILE__) . '/aq_resizer.php');
136
+ }
137
+ $extension = explode('.', $img_url);
138
+ $extension = strtolower(end($extension));
139
+ if( $extension != 'svg' ){
140
+ $img_url = aq_resize( $img_url, $width, $height, true, true, true);
141
+ }
142
+ return $img_url;
143
+ }
144
+
145
+ function acf_photo_gallery_image_fields( $args, $attachment_id, $field){
146
+ return array(
147
+ 'url' => array('type' => 'text', 'label' => 'URL', 'name' => 'url', 'value' => ($args['url'])?$args['url']:null),
148
+ 'target' => array('type' => 'checkbox', 'label' => 'Open in new tab', 'name' => 'target', 'value' => ($args['target'])?$args['target']:null),
149
+ 'title' => array('type' => 'text', 'label' => 'Title', 'name' => 'title', 'value' => ($args['title'])?$args['title']:null),
150
+ 'caption' => array('type' => 'textarea', 'label' => 'Caption', 'name' => 'caption', 'value' => ($args['caption'])?$args['caption']:null)
151
+ );
152
+ }
153
+ add_filter( 'acf_photo_gallery_image_fields', 'acf_photo_gallery_image_fields', 10, 3 );
154
+
155
+
156
+
157
+
158
+
159
+
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+
170
+
171
+
172
+
173
+ ?>
readme.txt ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === ACF Photo Gallery Field ===
2
+ Contributors: navzme
3
+ Tags: acf, advanced, custom, fields, photo, gallery, album, fancybox, litebox, lightbox
4
+ Requires at least: 3.8
5
+ Tested up to: 4.9.6
6
+ Stable tag: 1.6.2
7
+ License: GPLv2 or later
8
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
+
10
+ A cool plugin that extends the Advanced Custom Fields (ACF) functionality to add ‘Photo Gallery’ to any post/pages of your choice.
11
+
12
+ == Description ==
13
+ This plugin is alternative of ACF Gallery Pro.
14
+
15
+ We are just a lightweight extension of Advanced Custom Field (ACF) that adds ‘Photo Gallery’ field to any post/pages on your WordPress website.
16
+
17
+ * Visually create your Fields
18
+ * Add multiple photos and you can also modify title, caption and link to anything
19
+ * Assign your fields to multiple edit pages (via custom location rules)
20
+ * Easily load data through a simple and friendly API
21
+ * Uses the native WordPress custom post type for ease of use and fast processing
22
+ * Uses the native WordPress metadata for ease of use and fast processing
23
+
24
+ = Usage =
25
+ The following example is using Twitter Bootstrap framework to layout. You can use any framework of your choice.
26
+
27
+ `<?php
28
+ //Get the images ids from the post_metadata
29
+ $images = acf_photo_gallery('gallery_images', $post->ID);
30
+ //Check if return array has anything in it
31
+ if( count($images) ):
32
+ //Cool, we got some data so now let's loop over it
33
+ foreach($images as $image):
34
+ $id = $image['id']; // The attachment id of the media
35
+ $title = $image['title']; //The title
36
+ $caption= $image['caption']; //The caption
37
+ $full_image_url= $image['full_image_url']; //Full size image url
38
+ $full_image_url = acf_photo_gallery_resize_image($full_image_url, 262, 160); //Resized size to 262px width by 160px height image url
39
+ $thumbnail_image_url= $image['thumbnail_image_url']; //Get the thumbnail size image url 150px by 150px
40
+ $url= $image['url']; //Goto any link when clicked
41
+ $target= $image['target']; //Open normal or new tab
42
+ $alt = get_field('photo_gallery_alt', $id); //Get the alt which is a extra field (See below how to add extra fields)
43
+ $class = get_field('photo_gallery_class', $id); //Get the class which is a extra field (See below how to add extra fields)
44
+ ?>
45
+ <div class="col-xs-6 col-md-3">
46
+ <div class="thumbnail">
47
+ <?php if( !empty($url) ){ ?><a href="<?php echo $url; ?>" <?php echo ($target == 'true' )? 'target="_blank"': ''; ?>><?php } ?>
48
+ <img src="<?php echo $full_image_url; ?>" alt="<?php echo $title; ?>" title="<?php echo $title; ?>">
49
+ <?php if( !empty($url) ){ ?></a><?php } ?>
50
+ </div>
51
+ </div>
52
+ <?php endforeach; endif; ?>`
53
+
54
+ = Add Extra Fields =
55
+ To add extra fields add the following to your themes functions.php file.
56
+
57
+ `//Create extra fields called Altnative Text and Custom Classess
58
+ function my_extra_gallery_fields( $args, $attachment_id, $field ){
59
+ $args['alt'] = array('type' => 'text', 'label' => 'Altnative Text', 'name' => 'alt', 'value' => get_field($field . '_alt', $attachment_id) ); // Creates Altnative Text field
60
+ $args['class'] = array('type' => 'text', 'label' => 'Custom Classess', 'name' => 'class', 'value' => get_field($field . '_class', $attachment_id) ); // Creates Custom Classess field
61
+ return $args;
62
+ }
63
+ add_filter( 'acf_photo_gallery_image_fields', 'my_extra_gallery_fields', 10, 3 );`
64
+
65
+ = How to get values of extra fields =
66
+ You can use ACF helper function `get_field`
67
+
68
+ `get_field('photo_gallery_alt', $id);`
69
+ `get_field('photo_gallery_class', $id);`
70
+
71
+ = Pull caption from attachment caption field =
72
+ By default the caption is being pulled from description field. Add the following filter to your `function.php` to pull the caption from attachment caption field.
73
+ `add_filter( 'acf_photo_gallery_caption_from_attachment', '__return_true' );`
74
+
75
+ = Compatibility =
76
+ This ACF field type is compatible with:
77
+ * ACF 4
78
+ * ACF 5 (Coming Soon)
79
+
80
+ = Issues =
81
+ We have tested this plugins amongst the latest version of WordPress and famous themes and plugins. Just like any other WordPress plugin, this plugin can also cause issues with other themes and plugins. If you are facing issues making this plugin work on your WordPress site, please do ask for help in the support forum. This way we can help you out and prevent this issue from happening to someone else.
82
+ If you want to talk to me directly, you can contact me via my website <https://www.navz.me/>
83
+
84
+ == Installation ==
85
+
86
+ 1. Copy the `navz-photo-gallery` folder into your `wp-content/plugins` folder
87
+ 2. Activate the Advanced Custom Fields: Photo Gallery plugin via the plugins admin page
88
+ 3. Create a new field via ACF and select the Photo Gallery type
89
+ 4. Please refer to the description for more info regarding the field type settings
90
+
91
+ == Changelog ==
92
+ =1.6.2=
93
+ * [Bugfix] Keep data synced with the attachment data
94
+ * [Bugfix] Pull caption attachment caption using add filters
95
+ * [Bugfix] PHP 7.2 count() error
96
+
97
+ =1.6.1=
98
+ * [Bugfix] Edit image box disappears on click of pencil edit button reported by @rickytoof9
99
+
100
+ =1.6.0=
101
+ * [Bugfix] Error on saving post with empty gallery. Patch provided by @ugy
102
+ * [Bugfix] Showing multiple photo gallery fields in the same page reported by @rickytoof9
103
+ * [Added] Support for srcset. Special thanks to @ugy for the code
104
+
105
+ = 1.5.0 =
106
+ * [Added] Support for SVG
107
+ * [Added] Support for legacy PHP version
108
+ * [Added] Add extra fields
109
+
110
+ = 1.4.0 =
111
+ * [Added] Can sortable gallery images
112
+ * [Bugfix] Fixed the order to follow the sort order for gallery images
113
+
114
+ = 1.3.0 =
115
+ * Change the meta_key from acf field_key to acf field_name
116
+ * [Added] Helper function acf_photo_gallery() to pull images
117
+ * [Added] Helper function acf_photo_gallery_resize_image to resize the image on fly and save it
118
+ * [Bugfix] Issue with target parameter in config
119
+ * [Bugfix] Issue with url not saving properly
120
+
121
+ = 1.2.0 =
122
+ * [Bugfix] Support for WordPress 4.6
123
+ * [Added] Some changes on on the display
124
+ * [Added] Fetch the data from the database
125
+
126
+ = 1.1.0 =
127
+ * [Bugfix] Undefined index: acf-photo-gallery-field on file acf-photo_gallery-v4
128
+ * [Bugfix] When delete the photos from the gallery, the last photo was not deleting
129
+ * [Bugfix] Gallery photos was not saving in the database
130
+
131
+ = 1.0.0 =
132
+ * Initial Release.