The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

Enable Media Replace
[resolved] Deleting too many images (due to dimensions and naming) (4 posts)

  1. akv2
    Posted 3 years ago #

    Okay, so what I think is happening is that the Media Replace plugin is not quite as smart as it should be. We have a number of images that are named with the structure... house.png, house-door.png and house-door-window.png. When wordpress creates it's different sizes it saves those out with dashes, so those three images would be house-103x100.png, house-door-103x100.png, and house-door-window-103x100.png.

    I think the plugin says, okay... you want to replace house.png so I'm going to delete house.png and all it's sizes (house-X.png). In doing so, it deletes house-door.png (and it's sizes) and house-door-window.png (and it's sizes).

    Måns Jonasson, I should say that we really do appreciate this plugin and can't find anything out that accomplishes the same task. This is something that people should be aware of as they move forward... and if what I described is not actually the cause of the issue, please let me know.


  2. Måns Jonasson
    Plugin Author

    Posted 3 years ago #

    akv2: It's not quite that stupid, but almost. :-/

    The exakt deletion is:

    $prefix . "-*x*" . $suffix

    So if you upload a file called "image.jpg" it will delete all files matching "image-*x*.jpg"

    I agree that this is very stupid, but since WordPress lacks any way for me to find out what resized images DO exist, this is the closest I've gotten.

    If anybody knows of a way for me to improve on this method, please come forward!

  3. studioanino
    Posted 3 years ago #

    Måns, actually WP has that data stashed in the post_meta table. You can use wp_get_attachment_metadata to grab all existing sizes of an image, including custom sizes.

  4. Måns Jonasson
    Plugin Author

    Posted 3 years ago #

    Thanks John, for some reason that wasn't working when I first developed the plugin, but I just tried it and it works now, so I'll change the method for file deletion in the next version.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Enable Media Replace
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic