mindkomm / timmy

Advanced image handling for Timber.
MIT License
171 stars 13 forks source link

How do you handle derivative image path pattern(s) #24

Open drzraf opened 5 years ago

drzraf commented 5 years ago

Hi, sorry for the support issue. I'm switching to Timmy and formalize my thumbnail size but hit a couple of issues.

I've an hundred of posts referencing derivative images (whether within ACF whether in the post_content). All these will break as a soon as I switch to Timmy (and regenerate thumbnails / purge old derivative files) because the filename pattern changes from, eg, image-A-300x252.png to image-A-300x0-c-default.png.

  1. It's far from future-proof, how do you handle this situation?
  2. Do you know about existing WP bugreports related to this (and the lack of an intermediary and height/width-agnostic representation of inlined images)?
  3. Is there a foolproof method/hook to store derivative images in completely different upload subfolder (to make identification of their references within the database easier)?
    1. And if yes, would you think using the format name instead of actual dimension for filename could be a realistic way to solve this, eg, image-A-medium.png?
gchtr commented 5 years ago

Hey Raphaël!

No worries! I’m actually amazed there aren’t more support questions.

About your questions:

  1. Unfortunately, I’ve never a had a case like yours. But I’d like to make this work. Can you make more concrete examples for the images that break in the post content as well as for ACF? I would like to replicate this, so I can think about a solution.
  2. No, I don’t. But I didn’t go and dig in the trac tickets, either. What do you mean with «lack of an intermediary height/width-agnostic representation of inlined images»?
  3. Timmy relies on Timber’s resize function. I never tried to change the folders or filenames of the generated files, because apparently (from seeing a lot of issues in Timber) this leads to a lot special cases that need to be catched and handled separately. It’s far from foolproof and very fragile. I guess image handling in Timber could be improved. But there’s so much to consider. It’s really hard to come up with a solution that benefits everyone.
  4. We would have to explore this further. A benefit of the dimensions in the filename is that you can change dimensions and don’t have to regenerate all thumbnails, because the new size is generated on the fly. A downside is that you end up with invalid image sizes, so you would have to regenerate images anyway.