Bloke / smd_thumbnail

Multiple image thumbnails of arbitrary dimensions
GNU General Public License v2.0
8 stars 4 forks source link

silently fails to manually upload a webp thumbnail image #28

Closed phiw13 closed 3 years ago

phiw13 commented 3 years ago

automatic thumbnail generation works fine manual upload fails.

STR

Expected: image uploaded Actual result: no image is uploaded; no thumbnail is displayed in the panel and the image is nowhere to be found on the file system.

Debugging mode is turned on but no message is displayed.

PHP 7.4 on Dreamhost servers (CentOS) PHP 8, Homebrew edition locally (macOS 11)

The server logs (apache/php) are silent - no error. All 25+ known methods of searching the macOS file system return a blank.

Manual upload of jpg/png images works fine

Bloke commented 3 years ago

A few things at play here:

  1. The script that hijacks the core's thumbnail creation process (smd_thumb_insert) does a redirect after it completes and 'forgets' the success/failure message so it never displays. No idea how to get round that cleanly.
  2. The plugin doesn't support webp yet. Easy to add.
  3. Even when it does support webp (fairly easy to add), core does not support the concept of multiple thumbnails of different types. Our tables are simply not geared up for this eventuality yet. The assumption is that the extension of the main image - stored in the database table - is the same extension as all thumbnails. There's no way around this at present.

The only way to do this is to manually FTP replacement thumbnails of different types up to the server and reference them by hand in srcset/picture tags. Messy. It's exactly the same in core. If you try to replace a thumb of a different type, it will be "ignored" because the extension doesn't match that of the main image.

Bloke commented 3 years ago

See 76598900.

phiw13 commented 3 years ago

plugin doesn't support webp yet. Easy to add.

ah… that… I was assuming it automatically supported the same types as Core (or inherited them).

does not support the concept of multiple thumbnails of different types

yeah, I know and was not trying to be all that creative. I was simply trying to replace the automatically generated (bloated) thumbs with manually created ones (the whole time dealing with .webp images). Not trying to mix anything.

Dealing with multiple types for one “master” upload is something we hope will be possible in a future TXP, as discussed in the forum.

I will test tomorrow, but if manual upload of webp thumbs is possible with mentioned patch, this issue can be closed.

Bloke commented 3 years ago

I was assuming it automatically supported the same types as Core (or inherited them).

Sadly not. There's an annoying amount of repetition in the smd_thumbnail plugin because the core API isn't (yet) flexible enough to let plugins play in innovative ways. It's getting there, and hopefully we can make great strides in 4.9 in this arena.

I was simply trying to replace the automatically generated (bloated) thumbs with manually created ones (the whole time dealing with .webp images). Not trying to mix anything.

Ah cool. In which case, the patch should sort you out. It works in my (limited) tests, albeit with the annoying caveat that it doesn't tell you it's done it via a status message. Grrr...

phiw13 commented 3 years ago

In which case, the patch should sort you out. It works in my (limited) tests, albeit with the annoying caveat that it doesn't tell you it's done it via a status message. Grrr…

Cool, uploading those thumbs in .webp format now works, afaict. Tested with Safari and Firefox, PHP8 and PHP 7.4. The lack of status message is a bit of a nuisance of course.

Closing this as the main part (uploading .webp images) is done.

Bloke commented 3 years ago

uploading those thumbs in .webp format now works

Thank you for testing.

The lack of status message is a bit of a nuisance of course.

Yes. I spent some time yesterday trying to hack solutions to no avail. I suspect the smd_thumb_insert() function should really hook into the thumbnail management callbacks in a different manner so I can do what's necessary (replace a given thumb) and then return cleanly with a $message instead of forcing a nasty redirect due to the headers already being sent by the time the plugin is invoked. There has to be some way of triggering announce() because @bloatware does it in core when uploading multiple files. Maybe I need to make this process run via Ajax so it doesn't need a refresh.

Hmmmm. Will put it in the back of my head and see if there's a way we can improve the image API when we do the grid/multi thumbs in core. Although that'll obviate the need for the plugin with luck!