Enable Media Replace - Version 3.6.2

Version Description

Release date: November 8th, 2021 * Fix: there was an issue in file.php with checking mime-type, resulting in weird mime-type values in certain cases (thanks @dougaxe1 for the PR); * Fix: if target mime type returns empty, don't store that; * Tweak: removed old notification about SPIO.

Download this release

Release Info

Developer petredobrescu
Plugin Icon 128x128 Enable Media Replace
Version 3.6.2
Comparing to
See all releases

Code changes from version 3.6.1 to 3.6.2

classes/emr-plugin.php CHANGED
@@ -399,14 +399,14 @@ class EnableMediaReplacePlugin
399
  $current_screen = get_current_screen();
400
 
401
  $crtScreen = function_exists("get_current_screen") ? get_current_screen() : (object)array("base" => false);
402
-
403
  if(current_user_can( 'activate_plugins' ) && !get_option( 'emr_news') && !is_plugin_active('shortpixel-image-optimiser/wp-shortpixel.php')
404
  && ($crtScreen->base == "upload" || $crtScreen->base == "plugins")
405
  //for network installed plugins, don't display the message on subsites.
406
  && !(function_exists('is_multisite') && is_multisite() && is_plugin_active_for_network('enable-media-replace/enable-media-replace.php') && !is_main_site()))
407
  {
408
  require_once($this->plugin_path . '/views/notice.php');
409
- }
410
  }
411
 
412
  public function display_network_notices() {
399
  $current_screen = get_current_screen();
400
 
401
  $crtScreen = function_exists("get_current_screen") ? get_current_screen() : (object)array("base" => false);
402
+ /*
403
  if(current_user_can( 'activate_plugins' ) && !get_option( 'emr_news') && !is_plugin_active('shortpixel-image-optimiser/wp-shortpixel.php')
404
  && ($crtScreen->base == "upload" || $crtScreen->base == "plugins")
405
  //for network installed plugins, don't display the message on subsites.
406
  && !(function_exists('is_multisite') && is_multisite() && is_plugin_active_for_network('enable-media-replace/enable-media-replace.php') && !is_main_site()))
407
  {
408
  require_once($this->plugin_path . '/views/notice.php');
409
+ } */
410
  }
411
 
412
  public function display_network_notices() {
classes/file.php CHANGED
@@ -38,7 +38,7 @@ class emrFile
38
  $filedata = wp_check_filetype_and_ext($this->file, $this->fileName);
39
  // This will *not* be checked, is not meant for permission of validation!
40
  // Note: this function will work on non-existing file, but not on existing files containing wrong mime in file.
41
- $this->fileMime = (isset($filedata['type']) && strlen($filedata['type'] > 0)) ? $filedata['type'] : false;
42
 
43
  if ($this->fileMime == false && strlen($this->file) > 0 && function_exists('mime_content_type') && $this->exists)
44
  {
38
  $filedata = wp_check_filetype_and_ext($this->file, $this->fileName);
39
  // This will *not* be checked, is not meant for permission of validation!
40
  // Note: this function will work on non-existing file, but not on existing files containing wrong mime in file.
41
+ $this->fileMime = (isset($filedata['type']) && strlen($filedata['type']) > 0) ? $filedata['type'] : false;
42
 
43
  if ($this->fileMime == false && strlen($this->file) > 0 && function_exists('mime_content_type') && $this->exists)
44
  {
classes/replacer.php CHANGED
@@ -144,7 +144,7 @@ class Replacer
144
  // update the file attached. This is required for wp_get_attachment_url to work.
145
  $updated = update_attached_file($this->post_id, $this->targetFile->getFullFilePath() );
146
  if (! $updated)
147
- Log::addError('Update Attached File reports as not updated');
148
 
149
  $this->target_url = $this->getTargetURL(); //wp_get_attachment_url($this->post_id);
150
 
@@ -165,10 +165,12 @@ class Replacer
165
 
166
  // Check and update post mimetype, otherwise badly coded plugins cry.
167
  $post_mime = get_post_mime_type($this->post_id);
168
- // update DB post mime type, if somebody decided to mess it up.
169
 
170
- if ($this->targetFile->getFileMime() !== $post_mime)
 
171
  {
 
172
  \wp_update_post(array('post_mime_type' => $this->targetFile->getFileMime(), 'ID' => $this->post_id));
173
  }
174
 
144
  // update the file attached. This is required for wp_get_attachment_url to work.
145
  $updated = update_attached_file($this->post_id, $this->targetFile->getFullFilePath() );
146
  if (! $updated)
147
+ Log::addError('Update Attached File reports as not updated or same value');
148
 
149
  $this->target_url = $this->getTargetURL(); //wp_get_attachment_url($this->post_id);
150
 
165
 
166
  // Check and update post mimetype, otherwise badly coded plugins cry.
167
  $post_mime = get_post_mime_type($this->post_id);
168
+ $target_mime = $this->targetFile->getFileMime();
169
 
170
+ // update DB post mime type, if somebody decided to mess it up, and the target one is not empty.
171
+ if ($target_mime !== $post_mime && strlen($target_mime) > 0)
172
  {
173
+
174
  \wp_update_post(array('post_mime_type' => $this->targetFile->getFileMime(), 'ID' => $this->post_id));
175
  }
176
 
classes/uihelper.php CHANGED
@@ -192,7 +192,7 @@ class UIHelper
192
  protected function getImageSizes($attach_id, $size = 'thumbnail')
193
  {
194
  $data = wp_get_attachment_image_src($attach_id, $size);
195
- $width = $data[1];
196
  //$mime_type = get_post_mime_type($attach_id);
197
  $file = get_attached_file($attach_id);
198
  $mime_type = wp_get_image_mime($file);
192
  protected function getImageSizes($attach_id, $size = 'thumbnail')
193
  {
194
  $data = wp_get_attachment_image_src($attach_id, $size);
195
+ $width = isset($data[1]) ? $data[1] : 0;
196
  //$mime_type = get_post_mime_type($attach_id);
197
  $file = get_attached_file($attach_id);
198
  $mime_type = wp_get_image_mime($file);
enable-media-replace.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Enable Media Replace
4
  * Plugin URI: https://wordpress.org/plugins/enable-media-replace/
5
  * Description: Enable replacing media files by uploading a new file in the "Edit Media" section of the WordPress Media Library.
6
- * Version: 3.6.1
7
  * Author: ShortPixel
8
  * Author URI: https://shortpixel.com
9
  * GitHub Plugin URI: https://github.com/short-pixel-optimizer/enable-media-replace
@@ -27,7 +27,7 @@
27
 
28
  namespace EnableMediaReplace;
29
 
30
- define('EMR_VERSION', '3.6.1');
31
 
32
  if ( ! defined( 'ABSPATH' ) ) {
33
  exit; // Exit if accessed directly.
3
  * Plugin Name: Enable Media Replace
4
  * Plugin URI: https://wordpress.org/plugins/enable-media-replace/
5
  * Description: Enable replacing media files by uploading a new file in the "Edit Media" section of the WordPress Media Library.
6
+ * Version: 3.6.2
7
  * Author: ShortPixel
8
  * Author URI: https://shortpixel.com
9
  * GitHub Plugin URI: https://github.com/short-pixel-optimizer/enable-media-replace
27
 
28
  namespace EnableMediaReplace;
29
 
30
+ define('EMR_VERSION', '3.6.2');
31
 
32
  if ( ! defined( 'ABSPATH' ) ) {
33
  exit; // Exit if accessed directly.
readme.txt CHANGED
@@ -3,9 +3,9 @@ Contributors: ShortPixel
3
  Donate link: https://www.paypal.me/resizeImage
4
  Tags: replace, attachment, media, files, replace image, replace jpg, change media, replace media, image, file
5
  Requires at least: 4.9.7
6
- Tested up to: 5.8.1
7
  Requires PHP: 5.6
8
- Stable tag: 3.6.1
9
 
10
  Easily replace any attached image/file by simply uploading a new file in the Media Library edit view - a real time saver!
11
 
@@ -47,7 +47,15 @@ If you want more control over the format used to display the time, you can use t
47
 
48
  == Changelog ==
49
 
 
 
 
 
 
 
 
50
  = 3.6.1 =
 
51
  Release date: October 27th, 2021
52
  * Fix: there was a broken image in one of the plugin notices;
53
  * Fix: added a check for the function `mime_content_type`, which doesn't seem to always be available on various hosts;
3
  Donate link: https://www.paypal.me/resizeImage
4
  Tags: replace, attachment, media, files, replace image, replace jpg, change media, replace media, image, file
5
  Requires at least: 4.9.7
6
+ Tested up to: 5.8
7
  Requires PHP: 5.6
8
+ Stable tag: 3.6.2
9
 
10
  Easily replace any attached image/file by simply uploading a new file in the Media Library edit view - a real time saver!
11
 
47
 
48
  == Changelog ==
49
 
50
+ = 3.6.2 =
51
+
52
+ Release date: November 8th, 2021
53
+ * Fix: there was an issue in file.php with checking mime-type, resulting in weird mime-type values in certain cases (thanks @dougaxe1 for the PR);
54
+ * Fix: if target mime type returns empty, don't store that;
55
+ * Tweak: removed old notification about SPIO.
56
+
57
  = 3.6.1 =
58
+
59
  Release date: October 27th, 2021
60
  * Fix: there was a broken image in one of the plugin notices;
61
  * Fix: added a check for the function `mime_content_type`, which doesn't seem to always be available on various hosts;