OFFLINE-GmbH / oc-responsive-images-plugin

Adds reponsive images capabilities to October CMS
MIT License
45 stars 26 forks source link

Webp issues with EDIT ME plugin. #70

Open TastySoul opened 4 years ago

TastySoul commented 4 years ago

Hi I get error when uploading images from frontend with enabled webp conversion. I quess it's rewriting upload path or messing with upload verification. Wouldnt it be better to detect support in plugin and change picture based on that ?

if( strpos( $_SERVER['HTTP_ACCEPT'], 'image/webp' ) == true ) {
    // webp is supported!
}
tobias-kuendig commented 4 years ago

I'll need some more info to help you here.

What error do you get? How do you upload the image? The plugin only rewrites requested images to their webp version. If the webp version does not exist, it tries to convert the original image to the webp format.

The plugin should not interfere wit your uploads.

Having the webp check server side would mean that every image that gets requested needs to be handled by PHP. This would result in a huge performance issue.

TastySoul commented 4 years ago

image Sadly there is not much more i can provide. Should be pretty easy to recreate. It's uploaded from frontend. I think its trying to verify image but it gets redirected.

tobias-kuendig commented 4 years ago

Check out the network tab and see what the server returns. Maybe there is some additional information. Also, check your storage/logs/system.log file.

TastySoul commented 4 years ago

image Not much info returned just 404. System log has no info at all.

TastySoul commented 4 years ago

Another idea for solution. What about using picture tag ? And automatically attach webp to it. Would get rid of htaccess.

<picture>
  <source srcset="img/awesomeWebPImage.webp" type="image/webp">
  <img src="img/creakyOldJPEG.jpg" alt="Alt Text!">
</picture>
tobias-kuendig commented 4 years ago

But then you would have to rewrite the markup of the page. And there is a big difference between a picture and a single img tag, this will break people's websites if it is applied automatically.

There's nothing stopping you from using the picture element manually. You can edit the .htaccess rules to your needs. All they do is redirect an image to the webp.php helper so it gets converted automatically.