• I do not know if this is a bug in your code or in wordpress. I was tracking a bug where if you add an image into a post, then crop it, sometimes that image would be deleted and would no longer exist.

    Lets say inside your theme you define the post thumbnail and another size to be the exact same.

    This is defined in functions.php

    set_post_thumbnail_size( 620, 400, true );
    add_image_size( 'post-thumb', 620, 400, true );

    Now if you upload an image thats 630 by 350 its width smaller than the required size, wordpress will resize it but it will not expand the image into the above size.

    It will create 2 images that are both 620 by 350. Now if you want to crop one of those images, your plugin will crop it, then it will resize the image to fit into the required size. The cropped image will now be 620 by 400. Now Somewhere the original image gets deleted (your plugin or wordpress), problem is if that original image is used on two sizes, its now missing for the other size.

    It will get recreated if you go back to the crop menu, but only if you go back to that menu, I’m guess wordpress or your plugin sees its been deleted and recreates it.

    Is your plugin the one that deletes the old image? If so would it be possible to only delete the old image if there are no other registered sizes of that same size. If not are you able to point me in the correct direction?

    Now this issue only exists if the width and I assume height is smaller then the defined size in wordpress and you crop the image and you have added the image into a wordpress post before cropping it.

    Any questions please feel free to ask, I would be more than happy to give more information if I have not explained this issue correctly.

    https://ww.wp.xz.cn/plugins/post-thumbnail-editor/

Viewing 1 replies (of 1 total)
  • Plugin Author sewpafly

    (@sewpafly)

    When you said the original image is deleted, you must mean the original thumbnail that wordpress creates, right? Yes, I delete the old thumbnail. If you want to suppress that you can listen for the wp_delete_file filter, and remove the filename (e.g. set it to null) to avoid this behavior (you would probably have to hook into wp_ajax_pte_ajax first).

    Let me know if you need help doing this.

Viewing 1 replies (of 1 total)

The topic ‘Old Image deletion bug’ is closed to new replies.