Forum Replies Created

Viewing 15 replies - 1 through 15 (of 20 total)
  • Thread Starter jashaw

    (@jashaw)

    I would agree that it is simpler to stop renaming the extension than it is to alter the code to change the extension in the meatadata. I consider myself to be more of a dabbler than a coder but it looks like you would have to add an extra step at each str_replace to also replace the extension.

    That being said, there are two places in your code that need to be changed.
    The code you pointed out above exists in the new_filename function (line 781) as well as the rename_media function (line 812).

    I changed it in both locations on my system and the plugin behaves as expected.

    2015-10-13 12:51:25: ** Rename Media: ACS.jpeg
    2015-10-13 12:51:25: New file should be: acs.jpeg
    2015-10-13 12:51:25: File /wp-content/uploads/ACS.jpeg renamed to /wp-content/uploads/acs.jpeg.
    2015-10-13 12:51:25: File /wp-content/uploads/ACS-150×75.jpeg renamed to /wp-content/uploads/acs-150×75.jpeg.
    2015-10-13 12:51:25: File /wp-content/uploads/ACS-250×125.jpeg renamed to /wp-content/uploads/acs-250×125.jpeg.
    2015-10-13 12:51:25: File /wp-content/uploads/ACS-600×300.jpeg renamed to /wp-content/uploads/acs-600×300.jpeg.
    2015-10-13 12:51:25: Post content like /wp-content/uploads/ACS.jpeg were replaced by /wp-content/uploads/acs.jpeg.
    2015-10-13 12:51:25: Metadata exactly like /wp-content/uploads/ACS.jpeg were replaced by /wp-content/uploads/acs.jpeg.
    2015-10-13 12:51:25: Post content like /wp-content/uploads/ACS-150×75.jpeg were replaced by /wp-content/uploads/acs-150×75.jpeg.
    2015-10-13 12:51:25: Metadata exactly like /wp-content/uploads/ACS-150×75.jpeg were replaced by /wp-content/uploads/acs-150×75.jpeg.
    2015-10-13 12:51:25: Post content like /wp-content/uploads/ACS-250×125.jpeg were replaced by /wp-content/uploads/acs-250×125.jpeg.
    2015-10-13 12:51:25: Metadata exactly like /wp-content/uploads/ACS-250×125.jpeg were replaced by /wp-content/uploads/acs-250×125.jpeg.
    2015-10-13 12:51:25: Post content like /wp-content/uploads/ACS-600×300.jpeg were replaced by /wp-content/uploads/acs-600×300.jpeg.
    2015-10-13 12:51:25: Metadata exactly like /wp-content/uploads/ACS-600×300.jpeg were replaced by /wp-content/uploads/acs-600×300.jpeg.
    2015-10-13 12:51:25: Slug acs renamed into acs.
    2015-10-13 12:51:25: Guid /wp-content/uploads/ACS.jpeg changed to /wp-content/uploads/acs.jpeg.

    Thread Starter jashaw

    (@jashaw)

    It seems I have misjudged the JPEG & PNG images plugin. They have verified that they are properly referencing the metadata to determine the file names. After running tests on a clean install with just these 2 plugins (yours and theirs), they have determined that the file path is not, in fact, matching what is being entered into the metadata.

    Fortunately, they were kind enough to find the issue with your code and share it.

    I have quickly checked the source of the Media File Renamer plugin, and found the cause. The error is caused by line 917 in media-file-renamer.php which reads:

    $meta[‘file’] = $this->str_replace( $noext_old_filename, $noext_new_filename, $meta[‘file’] );

    Note the ‘noext’ parts. It updates the “file” field of the metadata, which is necessary, but it only replaces the part without the extension. Because it doesn’t update the metadata correctly, the data in the database in regards to the original image is no longer up to date with what’s on the filesystem.
    Any other WordPress plugin using the image metadata that’s stored in the database and needs to access the actual original file on the filesystem will run into the same kinds of problems that it can’t be accessed.

    Thread Starter jashaw

    (@jashaw)

    Thanks for your further investigation. I wish everyone took as much pride in their work.

    Your test seems to be producing slightly different results than what I was observing on my system. In my case, the files themselves where still bearing the .jpeg extension, which is what lead me to assume that your plugin was not properly referencing the metadata for all file names. Unfortunately, I am not skilled enough with php to find errors in code, as you have done, so my observations were all I had to go on. Given a test on a clean install I cannot argue with your results since I cannot disable all of my plugins without adversely affecting our site. ( I hope that doesn’t mean I have another plugin issue yet to be flushed out.)

    Please accept my apologies for my incorrect conclusions. I will certainly update the support discussion with the Media File Renamer plugin.

    Thanks again for working on this.

    What about using a redirection to point users to a fictitious url setup in wordfence.

    redirect /.+\/info.php https://www.example.com/honey/pot/url

    Thread Starter jashaw

    (@jashaw)

    After a thorough investigation into what was causing this issue, here is what I found:
    The Media File Renamer, when renaming “.jpeg” files, was using .jpg for the original file name while using “.jpeg” for the thumbnail images. See the issue here.

    What this tells me about your plugin, is that you are not using the metadata to determine the file names used for thumbnails at some point in your code. While its hard to call this a bug, I think it is safe to say that it is a weakness. Changing the way you find those files would increase the stability of your plugin, especially with regard to conflicting with other plugins.

    Thread Starter jashaw

    (@jashaw)

    So basically you upload a jpeg file, the normal file is renamed with a new jpg extension but for the alternative images they are using a jpeg extension? Is that it?

    That’s the issue. I’m afraid the it is causing me more than just cosmetic trouble. WordPress itself is fine but it is wreaking havoc with a couple of my plugins.
    In the case of JPEG & PNG images, you could easily argue that its bad programming. The plugin seems to be looking for a regex pattern to find files rather than querying the metadata.
    In the case of Regenerate Thumbnails its not so cut and dry. That plugin completely ignores the metadata and the files. It simply repeats the original thumbnail creation process that WordPress itself uses. Since the original file now uses “.jpg”, so do the new thumbnails. Once again this does not break any links but I now have double the thumbnails for that image, with old links pointing to the “.jpeg” file and new links pointing to the “.jpg” file.

    While I plan to address the weakness of the JPEG & PNG images plugin with the author, alterations to this plugin would fix them all. I wouldn’t call it an immediate need since its easy enough to rename jpeg files to jpg files before uploading them but it would be a good item to plan on adding to an upcoming release.

    Thread Starter jashaw

    (@jashaw)

    Wow 3 times….I guess the button was working.

    I think I understand your confusion. The physical files match the log, as does the metadata. The filename (left of the period) is fine. It’s the file extention that is the problem. Files that are renamed with a “jpeg” extension behave different than other extensions because your are changing the extension from “jpeg” to “jpg”. The problem is that it is only working for the original file and not the thumbnails.

    Look at the file extension in the logs…

    wp-content/uploads/ACS.jpeg were replaced by wp-content/uploads/acs.jpg.
    wp-content/uploads/ACS-150×75.jpeg were replaced by wp-content/uploads/acs-150×75.jpeg.

    Thread Starter jashaw

    (@jashaw)

    2015-10-07 17:20:34: ** Rename Media: ACS.jpeg
    2015-10-07 17:20:34: New file should be: acs.jpg
    2015-10-07 17:20:34: File wp-content/uploads/ACS.jpeg renamed to wp-content/uploads/acs.jpg.
    2015-10-07 17:20:34: File wp-content/uploads/ACS-150×75.jpeg renamed to wp-content/uploads/acs-150×75.jpeg.
    2015-10-07 17:20:34: File wp-content/uploads/ACS-250×125.jpeg renamed to wp-content/uploads/acs-250×125.jpeg.
    2015-10-07 17:20:34: File wp-content/uploads/ACS-600×300.jpeg renamed to wp-content/uploads/acs-600×300.jpeg.
    2015-10-07 17:20:34: Post content like wp-content/uploads/ACS.jpeg were replaced by wp-content/uploads/acs.jpg.
    2015-10-07 17:20:34: Metadata exactly like wp-content/uploads/ACS.jpeg were replaced by wp-content/uploads/acs.jpg.
    2015-10-07 17:20:34: Post content like wp-content/uploads/ACS-150×75.jpeg were replaced by wp-content/uploads/acs-150×75.jpeg.
    2015-10-07 17:20:34: Metadata exactly like wp-content/uploads/ACS-150×75.jpeg were replaced by wp-content/uploads/acs-150×75.jpeg.
    2015-10-07 17:20:34: Post content like wp-content/uploads/ACS-250×125.jpeg were replaced by wp-content/uploads/acs-250×125.jpeg.
    2015-10-07 17:20:34: Metadata exactly like wp-content/uploads/ACS-250×125.jpeg were replaced by wp-content/uploads/acs-250×125.jpeg.
    2015-10-07 17:20:34: Post content like wp-content/uploads/ACS-600×300.jpeg were replaced by wp-content/uploads/acs-600×300.jpeg.
    2015-10-07 17:20:34: Metadata exactly like wp-content/uploads/ACS-600×300.jpeg were replaced by wp-content/uploads/acs-600×300.jpeg.
    2015-10-07 17:20:34: Slug acs renamed into acs.
    2015-10-07 17:20:34: Guid wp-content/uploads/ACS.jpeg changed to wp-content/uploads/acs.jpg.

    Thread Starter jashaw

    (@jashaw)

    Here is part of the log with site specific data removed.

    2015-10-07 17:20:34: ** Rename Media: ACS.jpeg
    2015-10-07 17:20:34: New file should be: acs.jpg
    2015-10-07 17:20:34: File wp-content/uploads/ACS.jpeg renamed to wp-content/uploads/acs.jpg.
    2015-10-07 17:20:34: File wp-content/uploads/ACS-150x75.jpeg renamed to wp-content/uploads/acs-150x75.jpeg.
    2015-10-07 17:20:34: File wp-content/uploads/ACS-250x125.jpeg renamed to wp-content/uploads/acs-250x125.jpeg.
    2015-10-07 17:20:34: File wp-content/uploads/ACS-600x300.jpeg renamed to wp-content/uploads/acs-600x300.jpeg.
    2015-10-07 17:20:34: Post content like wp-content/uploads/ACS.jpeg were replaced by wp-content/uploads/acs.jpg.
    2015-10-07 17:20:34: Metadata exactly like wp-content/uploads/ACS.jpeg were replaced by wp-content/uploads/acs.jpg.
    2015-10-07 17:20:34: Post content like wp-content/uploads/ACS-150x75.jpeg were replaced by wp-content/uploads/acs-150x75.jpeg.
    2015-10-07 17:20:34: Metadata exactly like wp-content/uploads/ACS-150x75.jpeg were replaced by wp-content/uploads/acs-150x75.jpeg.
    2015-10-07 17:20:34: Post content like wp-content/uploads/ACS-250x125.jpeg were replaced by wp-content/uploads/acs-250x125.jpeg.
    2015-10-07 17:20:34: Metadata exactly like wp-content/uploads/ACS-250x125.jpeg were replaced by wp-content/uploads/acs-250x125.jpeg.
    2015-10-07 17:20:34: Post content like wp-content/uploads/ACS-600x300.jpeg were replaced by wp-content/uploads/acs-600x300.jpeg.
    2015-10-07 17:20:34: Metadata exactly like wp-content/uploads/ACS-600x300.jpeg were replaced by wp-content/uploads/acs-600x300.jpeg.
    2015-10-07 17:20:34: Slug acs renamed into acs.
    2015-10-07 17:20:34: Guid wp-content/uploads/ACS.jpeg changed to wp-content/uploads/acs.jpg.

    Thread Starter jashaw

    (@jashaw)

    here is a portion of the log file, with site specific data stripped.

    2015-10-07 17:20:34: ** Rename Media: ACS.jpeg
    2015-10-07 17:20:34: New file should be: acs.jpg
    2015-10-07 17:20:34: File wp-content/uploads/ACS.jpeg renamed to wp-content/uploads/acs.jpg.
    2015-10-07 17:20:34: File wp-content/uploads/ACS-150x75.jpeg renamed to wp-content/uploads/acs-150x75.jpeg.
    2015-10-07 17:20:34: File wp-content/uploads/ACS-250x125.jpeg renamed to wp-content/uploads/acs-250x125.jpeg.
    2015-10-07 17:20:34: File wp-content/uploads/ACS-600x300.jpeg renamed to wp-content/uploads/acs-600x300.jpeg.
    2015-10-07 17:20:34: Post content like wp-content/uploads/ACS.jpeg were replaced by wp-content/uploads/acs.jpg.
    2015-10-07 17:20:34: Metadata exactly like wp-content/uploads/ACS.jpeg were replaced by wp-content/uploads/acs.jpg.
    2015-10-07 17:20:34: Post content like wp-content/uploads/ACS-150x75.jpeg were replaced by wp-content/uploads/acs-150x75.jpeg.
    2015-10-07 17:20:34: Metadata exactly like wp-content/uploads/ACS-150x75.jpeg were replaced by wp-content/uploads/acs-150x75.jpeg.
    2015-10-07 17:20:34: Post content like wp-content/uploads/ACS-250x125.jpeg were replaced by wp-content/uploads/acs-250x125.jpeg.
    2015-10-07 17:20:34: Metadata exactly like wp-content/uploads/ACS-250x125.jpeg were replaced by wp-content/uploads/acs-250x125.jpeg.
    2015-10-07 17:20:34: Post content like wp-content/uploads/ACS-600x300.jpeg were replaced by wp-content/uploads/acs-600x300.jpeg.
    2015-10-07 17:20:34: Metadata exactly like wp-content/uploads/ACS-600x300.jpeg were replaced by wp-content/uploads/acs-600x300.jpeg.
    2015-10-07 17:20:34: Slug acs renamed into acs.
    2015-10-07 17:20:34: Guid wp-content/uploads/ACS.jpeg changed to wp-content/uploads/acs.jpg.
    Thread Starter jashaw

    (@jashaw)

    There is definitely something going on here. Here is what I did.

    1. I disabled all plugins that were would not affect user experience.
    2. Uploaded a test file, ACS.jpeg.
    3. Navigated to the Media Library and clicked on the “Auto-Rename” button.
    4. Checked the post metadata only to find .jpeg still present.
    5. I repeated the test using the “File-Renamer” page with the same result.

    Here is the meta data that resulted:
    a:6:{s:5:"width";i:1112;s:6:"height";i:556;s:4:"file";s:8:"acs.jpeg";s:5:"sizes";a:3:{s:9:"thumbnail";a:4:{s:4:"file";s:15:"acs-150x75.jpeg";s:5:"width";i:150;s:6:"height";i:75;s:9:"mime-type";s:10:"image/jpeg";}s:6:"medium";a:4:{s:4:"file";s:16:"acs-250x125.jpeg";s:5:"width";i:250;s:6:"height";i:125;s:9:"mime-type";s:10:"image/jpeg";}s:5:"large";a:4:{s:4:"file";s:16:"acs-600x300.jpeg";s:5:"width";i:600;s:6:"height";i:300;s:9:"mime-type";s:10:"image/jpeg";}}s:10:"image_meta";a:11:{s:8:"aperture";i:0;s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";i:0;s:9:"copyright";s:0:"";s:12:"focal_length";i:0;s:3:"iso";i:0;s:13:"shutter_speed";i:0;s:5:"title";s:0:"";s:11:"orientation";i:0;}s:3:"url";s:7:"acs.jpg";}

    Thread Starter jashaw

    (@jashaw)

    Thanks for your reply. I have been able to correct the issue. It would seem that the alternate image files in the metadata was the problem, not the image itself.
    I was able to correct the issue using the Regenerate Thumbnails plugin. That replaced the original images and the metadata.

    Your plugins is working fine now. I have not yet found the cause of the original metadata corruption but I don’t think it is this plugin that is to blame.

    Thread Starter jashaw

    (@jashaw)

    I’ve determined that the last bit regarding the extra files is not related. My themes’s gallery function is creating those. As best I can tell, it creates them when the shortcode is processed, not when the images are uploaded.

    Thread Starter jashaw

    (@jashaw)

    We haven’t changed the theme.
    The only thing I can think of is a conflict between this plugin and JPEG & PNG images or Imsanity.

    I am having another strange issue which may or may not be related. Something keeps regenerating old images files in my uploads folder.
    For Example:
    2014h7.jpg is the original file.
    2014h7-a1f0a5e28ad2d402e34a0100db3a1a32.jpg keeps appearing. Its apparent that its a thumbnail after inspection but I can’t find that file in the metadata at all. I know for certain that your plugin did not cause it as this file was not renamed but I wonder if whatever is causing this issue is also causing the issue with your plugin.

    Thread Starter jashaw

    (@jashaw)

    At a quick glance, it appears that it was only the files renamed from .jpeg to .jpg were affected.

Viewing 15 replies - 1 through 15 (of 20 total)