• Hello,

    how can I change the destination folder of the new images? I would like save my image into the same folder of the original image.

    Thank you for support and for you plugin!

    D.

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author rosell.dk

    (@roselldk)

    Currently, there is no configuration option for that. I am however considering such an option. You are not the first who would like the converted images to be stored in the same folder as the original images.

    There is one caveat by storing in same folder though: There might be permission problems for images that don’t reside in the upload folder – ie. theme images. I’m considering how to handle that situation. One way could be to fall back at the current location for such images.

    If you cannot wait for the feature to be implemented, you can manually edit wod/webp-on-demand.php. In the line before the last line, insert this:

    $destination = $source . '.webp';

    Thread Starter damianocongedo

    (@damianocongedo)

    Thank you for your reply.

    I would have another request: I would like remove the extension of original file from the filename of new file.

    I ask to you this info because I am using another plugin that manage and <picture> tags on the front-end base on user device. But for this plugin works it is necessary that the folder and the filename would be the same.

    Thanks!

    Plugin Author rosell.dk

    (@roselldk)

    But with this plugin, there is really no need for pointing to webp version with a <picture> tag, as it takes take of serving the webp version to browsers that supports it.

    But perhaps there is some benefit of pointing to webp version directly in the HTML, which I am not aware of?

    Thread Starter damianocongedo

    (@damianocongedo)

    It is explained here: https://css-tricks.com/using-webp-images/

    In my point – base on the lecture about the Webp – it seams better manage also the front-end.

    Maybe you consider to add this feature in the future.

    PS: Can you help me about the previous question? ??

    Plugin Author rosell.dk

    (@roselldk)

    The article doesn’t really provide any reasons for managing it front end rather than server side.

    This article here however shows how using the picture tag can become unmanageable, when wanting to take more than just webp into account: https://developers.google.com/web/updates/2015/09/automating-resource-selection-with-client-hints. And it shows how all this trouble goes away by letting the server do the task of image selection.

    That said, I can however find one reason to use picture tag: It will not bring confusion to those who wants to download the image. With WebP Express, a user who downloads a jpg image in chromium will get a webp image – but the filename will have the jpg extension. So the user have a file with wrong file extension. Not ideal. And that thing will not happen with the <picture> tag.

    I shall return with code in a moment…

    Plugin Author rosell.dk

    (@roselldk)

    To have webp express save the converted files in the same directory, with ‘webp’ extension *instead* of original extension, edit wod/webp-on-demand.php. In the line before the last line, insert this:

    $destination = preg_replace('/\.(jpg|jpeg|png)$/', '.webp', $source);

    Plugin Author rosell.dk

    (@roselldk)

    Be aware that the conversion takes place when the jpeg is first requested. Until that, there will be no webp. So make sure that you request the jpeg at least once in your workflow.

    To avoid missing webp’s, you could create a rewrite rule which triggers when a webp is requested, but not found. When that happens, the server could look if there is a jpeg file in that directory, which matches the filename (besides the extension). If so – it could convert the jpeg to webp right away.

    I actually created a small php/.htaccess project for this very thing: https://github.com/rosell-dk/webp-realizer. Note that it is not a WordPress plugin and that I departed from the project, as I found the other way round to be more usable.

    Plugin Author rosell.dk

    (@roselldk)

    Oh yeah, the readme of webp-realized reminded me that the “frontend” approach also has the benefit that it requires no special setup of CDN’s

    Plugin Author rosell.dk

    (@roselldk)

    Btw: Which plugin is it that you are using for generating the picture tags?

    Thread Starter damianocongedo

    (@damianocongedo)

    Hi rosell,

    thank you for the support and information.

    The plugin is ShortPixel, it was developed for compression images but also has a feature for conversion to .webp and insert <picture> tag.

    I am using it only for the <picture> tag.

    It could be a great idea adding to your plugin this feature, in this case we could use just one plugin ??

    D.

    Plugin Author rosell.dk

    (@roselldk)

    Sorry, but I don’t think I shall add the ability to generate <picture> tags to the plugin. Not in near future anyway, as I rather want to focus on core functionality. But I think I shall implement custom destination folder. There are however other things on the roadmap that takes priority.

    Btw: I assume you are aware that the hacks I gave you here will have to be reimplemented when you update WebP Express

    Thread Starter damianocongedo

    (@damianocongedo)

    Yes, I know. So good, thank for you effort. I will wait for new plugin version!

    Plugin Author rosell.dk

    (@roselldk)

    Hi,

    Just released 0.8.0. But the feature you requested is not part of 0.8.0. But I think I will add it in 0.9.0. I have created an issue for it on github: https://github.com/rosell-dk/webp-express/issues/104

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Change destination folder’ is closed to new replies.