Image optimization for non standard upload path
-
Hi,
I have found, that if you change default upload path, then images are not being sent to webp conversion. Can you check that out ?
Second thing.
It would be great if we could turn lazy loading for certain class or URI, now we can only exclude.
-
Hi,
1) how did you change it ?
if the real path and databse record matches, even on non-standard path , it should also get processed
2) duly noted.
Best regards,
Hi,
By this funtion.
//Change upload per custom post type function custom_upload_directory( $args ) { $unaltered_post_type = array( 'page', 'post' ); if ( !isset( $_REQUEST['post_type'] ) ) { if ( isset( $_REQUEST['post'] ) ) { $post_type = get_post_type( $_REQUEST['post'] ); } elseif ( isset( $_REQUEST['post_id'] ) ) { $post_type = get_post_type( $_REQUEST['post_id'] ); } else { $post_type = ''; } } else { $post_type = $_REQUEST['post_type']; } if ( !empty( $post_type ) && !in_array( $post_type, $unaltered_post_type ) ) { //$args['basedir'] = str_replace('/wp-less', '', $args['basedir']); //$args['baseurl'] = str_replace('/wp-less', '', $args['baseurl']); $args['path'] = $args['basedir'] . '/' . $post_type; $args['url'] = $args['baseurl'] . '/' . $post_type; $args['subdir'] = $post_type; } return $args; } add_filter( 'upload_dir', 'custom_upload_directory' );Hi,
you said :
then images are not being sent to webp conversion
does it mean the images were optimized , but without webp format ?
or they don’t even get optm’ed at all ?
Best regards,
Hi,
Sorry it’s not that. It looks like jpg’s which are displayed via img are converted to webp. And those displayed via div + style bg-img, are not.
Hi,
currently webp replacement only supports
<imgtag andbackground-image: url("xxxx")if the images was loaded by other means , it won’t be able to filter and replaced
Best regards,
I know that, this is my html layout.
<div class="wrapCaseImgs" data-blx-scale="absolute" data-blx-container=""> <a href="https://brandoo.pl/portfolio/typ-prac/branding/home-pl/"><div class="paralaxElement coverBG " data-blx-depth="-.2" style="background-image: url("https://brandoo.pl/wp-content/uploads/portfolio/home_UI-paralax-th-bg.jpg"); transform: translate(42.54px, 13.22px) scale(1.3);"></div> <img data-blx-depth="0.15" class="paralaxElement coverFront coverFront1 " src="https://brandoo.pl/wp-content/uploads/portfolio/home_UI-paralax-th-front.png.webp" alt="home.pl" style="transform: translate(-31.905px, -9.915px) scale(1.225);" width="800" height="800"> </a></div>https://brandoo.pl/wp-content/uploads/portfolio/home_UI-paralax-th-bg.jpg.webp
because it doesn’t have webp version
The question is why, all pictures displayed via div style bg-img were not converted.
Hi,
well , sometimes the webp file could be larger than original , specially in case if origina was optimized before LSCWP touches it
another case I have seen before is the image has some kind of weird color profile thing that leads to webp generation failed
Best regards,
Ok, and yet Pagespeed is dumb eonach to mount about it 😉
Hi,
I tested on one of your images
original file -> 118 Kb
original file -> optimized file -> 45 Kb
original file -> optimized webp file -> 54 Kb
since the webp generator has fixed quality control , you can manually webp them with different parameter if you really really wish to get the webp file for them
Best regards,
Thx for testing it out.
The topic ‘Image optimization for non standard upload path’ is closed to new replies.