• Resolved ze3kr

    (@ze3kr)


    It seems the image upload through this plugin will not have srcset attribute? This attribute is for showing different sizes of image for different device.

    • This topic was modified 7 years, 6 months ago by ze3kr.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter ze3kr

    (@ze3kr)

    There definitely some thing break the srcset function, as I disabled this plugin, the srcset is correct. I am going to have a deep look in it.

    Thread Starter ze3kr

    (@ze3kr)

    I have found this bug, it is because the max_srcset_image_width is return 1 when this plugin is enabled. It returns 1600 when this plugin is disabled. I tried remove it and it works!

    function remove_max_srcset_image_width( $max_width ) {
        return false;
    }
    add_filter( 'max_srcset_image_width', 'remove_max_srcset_image_width', 99 );
    

    Hello,

    Thank you for pointing this out, will pass it to the development team.

    Thx for this trick, @ze3kr.
    I also noticed that the srcset images were loaded from the local uploads-folder instead of the google bucket.
    I created a quick fix (for my multisite setup, hence the $blog_id):

    function stateless_cdn_srcset($sources){
    	if (is_plugin_active( 'wp-stateless/wp-stateless-media.php' )) {
    		foreach ( $sources as $source ) {
    			$sources[ $source['value'] ][ 'url' ] = str_replace($uploads, 'https://storage.googleapis.com/'. $bucket . '/' . $blog_id . '/', $sources[ $source['value'] ][ 'url' ]);
    		}
    	}	
    	return $sources;
    }
    add_filter( 'wp_calculate_image_srcset', 'stateless_cdn_srcset');

    Cheers!

    Plugin Author Eric Sopp

    (@ideric)

    Thanks for the help @emiliopro!

    I’ve created an issue for this on github to track official support for srcset within WP-Stateless at https://github.com/wpCloud/wp-stateless/issues/18

    Feel free to follow along and add comments. Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘No srcset?’ is closed to new replies.