• Lauren

    (@oncecoupled)


    Is there planned support for srcset? It looks like that’s not enabled by default, but we’d like to take advantage of it!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Ajay

    (@ajay)

    What kind of code do you have in mine. I am not overly familiar with srcset. But, obviously happy to implement it to see how we can get it run better

    Thread Starter Lauren

    (@oncecoupled)

    Just the default WordPress implementation. I believe this is automatically added when using WordPress image functions, rather than manually outputting the tag.

    I didn’t read all the code, but theoretically replacing line 221 in media.php with wp_get_attachment_image() would work.

    Plugin Author Ajay

    (@ajay)

    I’ll see how wp_get_attachment_image is implemented but I think there is a bit more needed to be done to get the srcset working. I’ll put this on my todo list to get it added in

    Thread Starter Lauren

    (@oncecoupled)

    Hey @ajay I did a quick test for my own purposes and thought I’d share:

    Current implementation, which writes the img code: https://ibb.co/eVLysw
    $output .= '<img src="' . $postimage . '" alt="' . $post_title . '" title="' . $post_title . '" ' . $thumb_html . ' class="' . $class . '" />';

    Localized test with use of wp_get_attachment_image, which automatically outputs srcset assuming appropriately sized thumbnails exist: https://ibb.co/j9tweb

    $attachment = tptn_get_attachment_id_from_url( $postimage );
    		$attr_args = array(
    			'title' => $post_title,
    			'class' => $class,
    		);
            $output .= wp_get_attachment_image( $attachment, 'thumbnail-standard-retina', false, $attr_args );
    Plugin Author Ajay

    (@ajay)

    Thank you. I’ll take a look as well and see if I can get this to work within the plugin as it is a useful feature.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Support for srcset?’ is closed to new replies.