• Resolved vinigarcia87

    (@vinigarcia87)


    Hello!

    Wordpress adds a srcset attribute to images, to make better use of images on mobile devices. I notice that this doesn’t happen on this plugin.

    How can I make the plugin work with srcset?
    This is important for performance on mobile.

    Thanks a lot!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter vinigarcia87

    (@vinigarcia87)

    I figure it out!
    Problem is the TinyMCE.

    I solved this way:

    /**
      * Change the image markup to include srcset and sizes
      * when using tinyMCE editor
      */
    function add_srcset_and_sizes_to_tinymce_img_markup( $html, $id, $caption, $title, $align, $url, $size, $alt, $rel ) {
    	return wp_filter_content_tags( $html );
    }
    add_filter( 'image_send_to_editor', 'add_srcset_and_sizes_to_tinymce_img_markup', 10, 9 );

    This code process the content of TinyMCE the same way as the_content.
    Including the changes on images to add the scrset and sizes.

    Plugin Author simonpedge

    (@simonpedge)

    Ok, thanks for providing this info – somebody will probably find this useful in the future.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘srcset for images in mobile devices’ is closed to new replies.