• Resolved jashaw

    (@jashaw)


    This plugin doesn’t rename the extra files created by wordpress. Or at least, it isn’t always renaming them. The difference in naming was causing issues with some of my other plugins. I believe the issue is with files already uploaded, not new uploads. I can’t confirm that all of the files renamed had this issue but some certainly did.

    I was able to correct the issue by the Regenerate Thumbnails plugin. Unfortunately, that plugin didn’t replace the alternate sizes but, rather, created new ones and updated the metadata. My problem is fixed but I now have extra files in my uploads folder to remove.

    https://www.ads-software.com/plugins/media-file-renamer/

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

    (@jashaw)

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

    Plugin Author Jordy Meow

    (@tigroumeow)

    Hello,

    Mmm, it’s strange. But Media File Renamer use the metadata information available in WP to rename the files, if it’s not available then it doesn’t know that those files exist and will skip them. Maybe that’s what happened. Did you change theme one day, which use different image sizes? That would do this.

    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)

    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)

    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)

    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)

    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)

    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.

    Plugin Author Jordy Meow

    (@tigroumeow)

    Hello,

    To be honest I am a bit lost, I don’t see the issue. What is this issue now? The alternative images aren’t being renamed, but only the main image? What do your physical files look like after that log you shared here?

    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.

    Plugin Author Jordy Meow

    (@tigroumeow)

    Oh, I see… maybe ??

    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?

    Even that happens, the renaming in the posts should be actually following that.

    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.

    So the problem is the fact that jpeg doesn’t become jpg for all images? What would you expect to see? For me they all working it is just a bit weird that the extensions will look a bit different like this. I just wonder if there is a bigger issue for you that I don’t realize.

    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)

    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.

    Plugin Author Jordy Meow

    (@tigroumeow)

    Indeed, I think in the past I was not modifying the extension but since I do, that code became unsafe in the case there is a .jpeg. Can you thanks them for me? That’s cool they read the code and find this part.

    Now it might not be simple as it seems to fix. There would be many things to change and to test.

    What about changing this line:

    $ext = str_replace( 'jpeg', 'jpg', $path_parts['extension'] ); // In case of a jpeg extension, rename it to jpg

    To:

    $ext = $path_parts['extension']; // In case of a jpeg extension, rename it to jpg

    Wouldn’t hurt SEO and would make everything to work fine ?? Then later, I might do something for extension again but I will need to do proper implementation and testing. For now, we need a fix, and I think to simplify the code would be the best way to go.

    I am waiting for you to agree with this and I will push the new version.

    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.

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Alternate file sizes not renaming’ is closed to new replies.