media-experiments icon indicating copy to clipboard operation
media-experiments copied to clipboard

Keep date folder when optimizing existing media

Open swissspidy opened this issue 1 year ago • 4 comments

swissspidy avatar May 08 '24 13:05 swissspidy

This was reported by @PatriciaBT, but I actually cannot reproduce the issue. The date folder is already kept.

What I did:

  1. Deactivate Media Experiments
  2. Upload an image to a blog post from January 2024
  3. The image was stored in wp-content/uploads/2024/01
  4. Activate Media Experiments
  5. Edit the blog post, optimize the existing image
  6. The optimized image is also stored in wp-content/uploads/2024/01

Proof:

Screenshot 2024-05-10 at 15 11 58

Aside: the file names are incorrect, I'll fix that separately.

swissspidy avatar May 10 '24 13:05 swissspidy

Thank you @swissspidy When I add a file to a post from another month, it goes anyway in the current month, so it is indeed probably unrelated to the plugin. Also on your above image, it's month May (5) right?

patriciabt avatar May 10 '24 13:05 patriciabt

Ah, you're right! My bad 🤦

So I just looked into this more closely...

When I add a file to a post from another month, it goes anyway in the current month, so it is indeed probably unrelated to the plugin.

I think this is a bug in WordPress.

If I insert an image block in an old post from January, click on "Media Library" and upload an image in the popup there, the file is going to the January folder.

Screenshot 2024-05-10 at 16 39 51

(This is handled by media_handle_upload() and only works for post types other than page.

However, if I drag & drop an image into the editor, the file actually goes to the current month (May).

So this is inconsistent. I'll see how/where we can fix that in WordPress.


There is also another use case:

  1. Upload an image to a blog post from January, the image is stored in 2024/01.
  2. Create a new post in February and insert the existing January image
  3. Optimize the image
  4. Should it now be uploaded in 2024/01 (which is the date of the post) or in 2024/01 (the date of the original image)?

swissspidy avatar May 10 '24 14:05 swissspidy

I just opened https://core.trac.wordpress.org/ticket/61189 / https://github.com/WordPress/wordpress-develop/pull/6538 to fix this in core.

swissspidy avatar May 10 '24 15:05 swissspidy