Divi WordPress Theme
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress fix Reply To: Passing srcset to image attachment method

Discussion in 'Misc WordPress Requests' started by paralleljames, Feb 23, 2018.

  1. paralleljames

    Guest

    Reply To: Passing srcset to image attachment method, by paralleljames

    Hi Mahdi,

    wp_get_attachment_image will return a srcset

    If you sent the attachment_id and use a size that isn’t the smallest so medium, full or any you have defined it will then get a srcset, you can even define which image sizes you would like by supplying an array of image sizes to this.

    wp_get_attachment_image($image_id, ‘medium’);
    or
    wp_get_attachment_image($image_id, array(‘medium’, ‘full’));

    Cheers
    James

    Reply To: Passing srcset to image attachment method
     
    #1

Share This Page

Monarch Social Sharing Plugin