WP Retina 2x - Version 5.4.3

Version Description

  • Add: New hooks: wr2x_before_regenerate, wr2x_before_generate_thumbnails, wr2x_generate_thumbnails, wr2x_regenerate and wr2x_upload_retina.
  • Fix: Issues where happening with a few themes (actually the pagebuilder they use) after the last update.
  • Update: Lazysizes 4.0.4.
Download this release

Release Info

Developer TigrouMeow
Plugin Icon 128x128 WP Retina 2x
Version 5.4.3
Comparing to
See all releases

Code changes from version 5.4.2 to 5.4.3

Files changed (4) hide show
  1. ajax.php +47 -0
  2. core.php +12 -1
  3. readme.txt +6 -1
  4. wp-retina-2x.php +2 -2
ajax.php CHANGED
@@ -225,20 +225,42 @@ class Meow_WR2X_Ajax {
225
  }
226
 
227
  $attachmentId = intval( $_POST['attachmentId'] );
 
 
 
 
 
 
228
  $this->core->delete_attachment( $attachmentId, false );
229
 
230
  // Regenerate the Thumbnails
231
  $regenerate = get_option( 'wr2x_regenerate_thumbnails', false );
232
  if ( $regenerate ) {
 
 
 
 
 
 
233
  $file = get_attached_file( $attachmentId );
234
  $meta = wp_generate_attachment_metadata( $attachmentId, $file );
235
  wp_update_attachment_metadata( $attachmentId, $meta );
 
 
 
 
 
236
  }
237
 
238
  // Regenerate Retina
239
  $meta = wp_get_attachment_metadata( $attachmentId );
240
  $this->core->generate_images( $meta );
241
 
 
 
 
 
 
242
  // RESULTS FOR RETINA DASHBOARD
243
  $info = $this->core->html_get_basic_retina_info( $attachmentId, $this->core->retina_info( $attachmentId ) );
244
  $results[$attachmentId] = $info;
@@ -296,6 +318,12 @@ class Meow_WR2X_Ajax {
296
  $basepath = $pathinfo['dirname'];
297
  $retinafile = trailingslashit( $pathinfo['dirname'] ) . $pathinfo['filename'] . $this->core->retina_extension() . $pathinfo['extension'];
298
 
 
 
 
 
 
 
299
  if ( file_exists( $retinafile ) )
300
  unlink( $retinafile );
301
 
@@ -313,6 +341,12 @@ class Meow_WR2X_Ajax {
313
  chmod( $retinafile, 0644 );
314
  unlink( $tmpfname );
315
 
 
 
 
 
 
 
316
  // Get the results
317
  $info = $this->core->retina_info( $attachmentId );
318
  $this->core->update_issue_status( $attachmentId );
@@ -326,6 +360,7 @@ class Meow_WR2X_Ajax {
326
  ));
327
  die();
328
  }
 
329
  echo json_encode( array(
330
  'success' => true,
331
  'results' => $results,
@@ -399,6 +434,13 @@ class Meow_WR2X_Ajax {
399
  $attachmentId = (int) $_POST['attachmentId'];
400
  $meta = wp_get_attachment_metadata( $attachmentId );
401
  $current_file = get_attached_file( $attachmentId );
 
 
 
 
 
 
 
402
  $this->core->delete_attachment( $attachmentId, false );
403
  $pathinfo = pathinfo( $current_file );
404
  $basepath = $pathinfo['dirname'];
@@ -433,6 +475,11 @@ class Meow_WR2X_Ajax {
433
  $meta = wp_get_attachment_metadata( $attachmentId );
434
  $this->core->generate_images( $meta );
435
 
 
 
 
 
 
436
  // Get the results
437
  $info = $this->core->retina_info( $attachmentId );
438
  $results[$attachmentId] = $this->core->html_get_basic_retina_info( $attachmentId, $info );
225
  }
226
 
227
  $attachmentId = intval( $_POST['attachmentId'] );
228
+
229
+ /**
230
+ * @param $attachmentId ID of the attchment to regenerate
231
+ */
232
+ do_action( 'wr2x_before_regenerate', $attachmentId );
233
+
234
  $this->core->delete_attachment( $attachmentId, false );
235
 
236
  // Regenerate the Thumbnails
237
  $regenerate = get_option( 'wr2x_regenerate_thumbnails', false );
238
  if ( $regenerate ) {
239
+
240
+ /**
241
+ * @param $attachmentId ID of the attachment to generate thumbnails
242
+ */
243
+ do_action( 'wr2x_before_generate_thumbnails', $attachmentId );
244
+
245
  $file = get_attached_file( $attachmentId );
246
  $meta = wp_generate_attachment_metadata( $attachmentId, $file );
247
  wp_update_attachment_metadata( $attachmentId, $meta );
248
+
249
+ /**
250
+ * @param $attachmentId ID of the attachment that has generated its thumbnails
251
+ */
252
+ do_action( 'wr2x_generate_thumbnails', $attachmentId );
253
  }
254
 
255
  // Regenerate Retina
256
  $meta = wp_get_attachment_metadata( $attachmentId );
257
  $this->core->generate_images( $meta );
258
 
259
+ /**
260
+ * @param $attachmentId ID of the attachment that has been regenerated
261
+ */
262
+ do_action( 'wr2x_regenerate', $attachmentId );
263
+
264
  // RESULTS FOR RETINA DASHBOARD
265
  $info = $this->core->html_get_basic_retina_info( $attachmentId, $this->core->retina_info( $attachmentId ) );
266
  $results[$attachmentId] = $info;
318
  $basepath = $pathinfo['dirname'];
319
  $retinafile = trailingslashit( $pathinfo['dirname'] ) . $pathinfo['filename'] . $this->core->retina_extension() . $pathinfo['extension'];
320
 
321
+ /**
322
+ * @param $attachmentId ID of the attachment that the uploaded retina image is attached to
323
+ * @param $retinafile Path to the uploaded retina image
324
+ */
325
+ do_action( 'wr2x_before_upload_retina', $attachmentId, $retinafile );
326
+
327
  if ( file_exists( $retinafile ) )
328
  unlink( $retinafile );
329
 
341
  chmod( $retinafile, 0644 );
342
  unlink( $tmpfname );
343
 
344
+ /**
345
+ * @param $attachmentId ID of the attachment that the uploaded retina image is attached to
346
+ * @param $retinafile Path to the uploaded retina image
347
+ */
348
+ do_action( 'wr2x_upload_retina', $attachmentId, $retinafile );
349
+
350
  // Get the results
351
  $info = $this->core->retina_info( $attachmentId );
352
  $this->core->update_issue_status( $attachmentId );
360
  ));
361
  die();
362
  }
363
+
364
  echo json_encode( array(
365
  'success' => true,
366
  'results' => $results,
434
  $attachmentId = (int) $_POST['attachmentId'];
435
  $meta = wp_get_attachment_metadata( $attachmentId );
436
  $current_file = get_attached_file( $attachmentId );
437
+
438
+ /**
439
+ * @param $attachmentId ID of the attachment to replace
440
+ * @param $tmpfname Path to the temporary file that is to be the replacement
441
+ */
442
+ do_action( 'wr2x_before_replace', $attachmentId, $tmpfname );
443
+
444
  $this->core->delete_attachment( $attachmentId, false );
445
  $pathinfo = pathinfo( $current_file );
446
  $basepath = $pathinfo['dirname'];
475
  $meta = wp_get_attachment_metadata( $attachmentId );
476
  $this->core->generate_images( $meta );
477
 
478
+ /**
479
+ * @param $attachmentId ID of the attachment that has been replaced
480
+ */
481
+ do_action( 'wr2x_replace', $attachmentId );
482
+
483
  // Get the results
484
  $info = $this->core->retina_info( $attachmentId );
485
  $results[$attachmentId] = $this->core->html_get_basic_retina_info( $attachmentId, $info );
core.php CHANGED
@@ -998,6 +998,11 @@ class Meow_WR2X_Core {
998
  $issue = false;
999
  $id = $this->get_attachment_id( $meta['file'] );
1000
 
 
 
 
 
 
1001
  $this->log("* GENERATE RETINA FOR ATTACHMENT '{$meta['file']}'");
1002
  $this->log( "Full-Size is {$original_basename}." );
1003
 
@@ -1078,7 +1083,13 @@ class Meow_WR2X_Core {
1078
  $this->add_issue( $id );
1079
  else
1080
  $this->remove_issue( $id );
1081
- return $meta;
 
 
 
 
 
 
1082
  }
1083
 
1084
  function delete_images( $meta, $deleteFullSize = false ) {
998
  $issue = false;
999
  $id = $this->get_attachment_id( $meta['file'] );
1000
 
1001
+ /**
1002
+ * @param $id ID of the attachment whose retina image is to be generated
1003
+ */
1004
+ do_action( 'wr2x_before_generate_retina', $id );
1005
+
1006
  $this->log("* GENERATE RETINA FOR ATTACHMENT '{$meta['file']}'");
1007
  $this->log( "Full-Size is {$original_basename}." );
1008
 
1083
  $this->add_issue( $id );
1084
  else
1085
  $this->remove_issue( $id );
1086
+
1087
+ /**
1088
+ * @param $id ID of the attachment whose retina image has been generated
1089
+ */
1090
+ do_action( 'wr2x_generate_retina', $id );
1091
+
1092
+ return $meta;
1093
  }
1094
 
1095
  function delete_images( $meta, $deleteFullSize = false ) {
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: TigrouMeow
3
  Tags: retina, images, image, responsive, lazysizes, lazy, attachment, media, files, iphone, ipad, high-dpi
4
  Requires at least: 3.5
5
  Tested up to: 4.9
6
- Stable tag: 5.4.1
7
 
8
  Make your website look beautiful and crisp on modern displays by creating and displaying retina images. WP 4.4+ is also supported and enhanced.
9
 
@@ -33,6 +33,11 @@ More information and tutorial available one https://meowapps.com/wp-retina-2x/.
33
 
34
  == Changelog ==
35
 
 
 
 
 
 
36
  = 5.4.1 =
37
  * Fix: Issues where happening with a few themes (actually the pagebuilder they use) after the last update.
38
  * Update: Lazysizes 4.0.4.
3
  Tags: retina, images, image, responsive, lazysizes, lazy, attachment, media, files, iphone, ipad, high-dpi
4
  Requires at least: 3.5
5
  Tested up to: 4.9
6
+ Stable tag: 5.4.3
7
 
8
  Make your website look beautiful and crisp on modern displays by creating and displaying retina images. WP 4.4+ is also supported and enhanced.
9
 
33
 
34
  == Changelog ==
35
 
36
+ = 5.4.3 =
37
+ * Add: New hooks: wr2x_before_regenerate, wr2x_before_generate_thumbnails, wr2x_generate_thumbnails, wr2x_regenerate and wr2x_upload_retina.
38
+ * Fix: Issues where happening with a few themes (actually the pagebuilder they use) after the last update.
39
+ * Update: Lazysizes 4.0.4.
40
+
41
  = 5.4.1 =
42
  * Fix: Issues where happening with a few themes (actually the pagebuilder they use) after the last update.
43
  * Update: Lazysizes 4.0.4.
wp-retina-2x.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP Retina 2x
4
  Plugin URI: https://meowapps.com
5
  Description: Make your website look beautiful and crisp on modern displays by creating + displaying retina images.
6
- Version: 5.4.2
7
  Author: Jordy Meow
8
  Author URI: https://meowapps.com
9
  Text Domain: wp-retina-2x
@@ -29,7 +29,7 @@ if ( class_exists( 'Meow_WR2X_Core' ) ) {
29
  global $wr2x_picturefill, $wr2x_retinajs, $wr2x_lazysizes,
30
  $wr2x_retina_image, $wr2x_core;
31
 
32
- $wr2x_version = '5.4.2';
33
  $wr2x_retinajs = '2.0.0';
34
  $wr2x_picturefill = '3.0.2';
35
  $wr2x_lazysizes = '4.0.4';
3
  Plugin Name: WP Retina 2x
4
  Plugin URI: https://meowapps.com
5
  Description: Make your website look beautiful and crisp on modern displays by creating + displaying retina images.
6
+ Version: 5.4.3
7
  Author: Jordy Meow
8
  Author URI: https://meowapps.com
9
  Text Domain: wp-retina-2x
29
  global $wr2x_picturefill, $wr2x_retinajs, $wr2x_lazysizes,
30
  $wr2x_retina_image, $wr2x_core;
31
 
32
+ $wr2x_version = '5.4.3';
33
  $wr2x_retinajs = '2.0.0';
34
  $wr2x_picturefill = '3.0.2';
35
  $wr2x_lazysizes = '4.0.4';