stiolbe
Forum Replies Created
-
it works fine also with the beta.
here are the filters :
add_filter('webpc_uploads_root', function($path) { return $_SERVER['DOCUMENT_ROOT']; }); add_filter('webpc_uploads_path', function($path) { return 'uploads'; }); add_filter('webpc_uploads_webp', function($path) { return 'uploads-webpc'; }); add_filter('webpc_uploads_prefix', function($prefix) { return '/'; });it works fine with the latest stable, thanks a lot.
for portability I would just change it to :
add_filter('webpc_uploads_root', function($path) { return $_SERVER['DOCUMENT_ROOT']; });should I try with the beta version ?
I’m not sure I understand your request.
The website I’m working on is there :
https://preview.arrachetoiunoeil.com/
upload directory is
https://preview.arrachetoiunoeil.com/upload
to keep it simple let’s say documentroot is
/srv/www/wordplate/public
and upload dir is
/srv/www/wordplate/public/uploadsthe real server path I use locally (not for prod) and I can test is :
/var/www/com.arrachetoiunoeil/wordplate/public/uploadsThe plugin does not generate WebP files in the /uploads directory, because there is a risk of tampering with the original files
on another hand you have to add
upload-webpto.gitignoreor manage it manually with any deployment script, and manage its permission in addition touploads, which is a bit of a constraint…
maybe anuploads/webpc/structure would be more practical then ?hi Mateusz and thanks.
Same error message with the beta and no filter :
Server configuration error
The path for /uploads files does not exist (function is_dir() returns false). Please use the webpc_uploads_path filter to set the correct path. The current using path is: /srv/www/wordplate/public/wordpress//wp-content/uploads.
Unable to create or edit .htaccess file (function is_readable() or is_writable() returns false). Change directory permissions. The current using path of file is: /srv/www/wordplate/public/wordpress//wp-content/uploads/.htaccess. Please contact your server administrator.
I’m using wordplate and uploads directory correct path is :
/srv/www/wordplate/public/uploads- This reply was modified 6 years ago by stiolbe.
it works with :
add_filter('webpc_uploads_path', function($path) { return '../uploads'; }); add_filter('webpc_uploads_webp', function($path) { return '../uploads-webpc'; }); add_filter('webpc_htaccess_mod_rewrite', function($rules) { return ' RewriteEngine on RewriteCond %{REQUEST_FILENAME}\.webp -f RewriteRule "^(.*).(jpg|jpeg|png)$" "$1.$2.webp" '; });still I can’t get why WebP Converter generates webp in the original upload directory.
webpc_uploads_webp variable looks pretty much useless in that scenario.plus it seems to me that this plugin would be over-bloated.
Why wouldn’t it generates webp files in the original upload directory (that would be retrieved bywp_upload_dir()), alongside with the original jpgs (like it does by me, though it looks like a bug), then just redirect by adding this simple rules inuploads/.htaccess:RewriteEngine on RewriteCond %{REQUEST_FILENAME}\.webp -f RewriteRule "^(.*).(jpg|jpeg|png)$" "$1.$2.webp"I might be wrong but I can’t think of any case that would not get covered by this very simple method… (I mean under Apache)
when trying with
add_filter('webpc_uploads_path', function($path) { return '../uploads'; }); add_filter('webpc_uploads_webp', function($path) { return '../uploads'; });Server configuration error
The paths for /uploads files and for saving converted WebP files are the same. Change them using filters webpc_uploads_path or webpc_uploads_webp.
unfortunately last version seems broken again…
previous config returns :
Server configuration error
The path for /uploads files does not exist (function is_dir() returns false). Please use the webpc_uploads_path filter to set the correct path. The current using path is: /srv/www/wordplate/public/wordpress//uploads.
changed
functions.phpsetup to :add_filter('webpc_uploads_path', function($path) { return '../uploads'; }); add_filter('webpc_uploads_webp', function($path) { return '../uploads-webpc'; });and the error message is gone, but I never seems to have WebP image displayed…
the weird thing is
Regenerate imagesfunction seems to create webp images in the originaluploadsdirectory, alongside with the original jpg images, whileuploads/.htaccesscontinues to redirect touploads-webpc, where thy don’t exist…@hiteshmakvana thanks for your answer
Still I wonder : wouldn’t it be more practical to just add a time option to the [events] shortcode / function, than to copy paste the whole element ?
Especially considering there is already a daterangepicker filter GUI on top of the lists…
A simple next / current / previous selector would probably do the trick.
Another proposal : I think it would be simpler to just filter out these passed or previous events based on date end if it exists, date start otherwise than adding an extra “Listing Expiry Date” that comes to be mandatory when an event doesn’t have any end time.
I think it adds an unnecessary level of complexity : does anyone use another expiry date than the date of the event itself ?- This reply was modified 6 years, 1 month ago by stiolbe.
It works, thanks a lot !
So to anyone wishing to set it up with wordplate, juste add this to your
functions.php:add_filter('webpc_uploads_path', function($path) { return 'uploads'; }); add_filter('webpc_uploads_webp', function($path) { return 'uploads-webpc'; });it does work but you have to add the [PT] flag :
<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_ACCEPT} image/webp RewriteCond %{DOCUMENT_ROOT}/$1/uploads-webpc/$2.jpg.webp -f RewriteRule (.+)?uploads/(.+)\.jpg$ $1/uploads-webpc/$2.jpg.webp [PT,T=image/webp] RewriteCond %{HTTP_ACCEPT} image/webp RewriteCond %{DOCUMENT_ROOT}/$1/uploads-webpc/$2.jpeg.webp -f RewriteRule (.+)?uploads/(.+)\.jpeg$ $1/uploads-webpc/$2.jpeg.webp [PT,T=image/webp] RewriteCond %{HTTP_ACCEPT} image/webp RewriteCond %{DOCUMENT_ROOT}/$1/uploads-webpc/$2.png.webp -f RewriteRule (.+)?uploads/(.+)\.png$ $1/uploads-webpc/$2.png.webp [PT,T=image/webp] </IfModule>However I don’t get the diff between (.+)? and (.*)
Is there any ?After a bit of reading I think this is as clean as it can get :
<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_ACCEPT} image/webp RewriteCond %{DOCUMENT_ROOT}/$1/uploads-webpc/$2.jpg.webp -f RewriteRule ^(.*)uploads/(.+)\.jpg$ $1/uploads-webpc/$2.jpg.webp [PT,T=image/webp] RewriteCond %{HTTP_ACCEPT} image/webp RewriteCond %{DOCUMENT_ROOT}/$1/uploads-webpc/$2.jpeg.webp -f RewriteRule ^(.*)uploads/(.+)\.jpeg$ $1/uploads-webpc/$2.jpeg.webp [PT,T=image/webp] RewriteCond %{HTTP_ACCEPT} image/webp RewriteCond %{DOCUMENT_ROOT}/$1/uploads-webpc/$2.png.webp -f RewriteRule ^(.*)uploads/(.+)\.png$ $1/uploads-webpc/$2.png.webp [PT,T=image/webp] </IfModule>About
RewriteRuleand the leading slash :
https://stackoverflow.com/questions/4514627/apache-rewrite-rule-leading-slash
https://stackoverflow.com/questions/4514627/apache-rewrite-rule-leading-slash/4514696#4514696Without [PT], the rewriterule substitution string (second argument) with a leading slash refers to the root of the file system, plus there is no leading slash in the pattern string (first argument) in a per-directory context (which .htaccess is).
If you can confirm it works on a standard wordpress setup, maybe it would worth the shot to include this in a next release ?
Anyway thank you for your incredibly fast feedback !
concerning the image/webp issue with firefox :
https://bugzilla.mozilla.org/show_bug.cgi?id=1544231
I have not read everything though (sorry)the thing is RewriteRule doesn’t seem to work with a
/at first.nope sorry…
this does though :
RewriteEngine On RewriteCond %{HTTP_ACCEPT} image/webp RewriteCond %{DOCUMENT_ROOT}/$1/uploads-webpc/$2.jpg.webp -f RewriteRule (.*)uploads/(.+)\.jpg$ $1uploads-webpc/$2.jpg.webp [T=image/webp] RewriteCond %{HTTP_ACCEPT} image/webp RewriteCond %{DOCUMENT_ROOT}/$1/uploads-webpc/$2.jpeg.webp -f RewriteRule (.*)uploads/(.+)\.jpeg$ $1uploads-webpc/$2.jpeg.webp [T=image/webp] RewriteCond %{HTTP_ACCEPT} image/webp RewriteCond %{DOCUMENT_ROOT}/$1/uploads-webpc/$2.png.webp -f RewriteRule (.*)uploads/(.+)\.png$ $1uploads-webpc/$2.png.webp [T=image/webp]i guess it should work on standard wordpress either but i’m not convinced with its cleanness.