I'm working on advanced responsive images in a Drupal 8 view, designed to suggest showing different images at various screen sizes around the Bootstrap theme.
Is there a way I can prevent everything up to the ":" from being stripped/filtered out in my views field output sizes attribute?
My views field rewrite looks like this:
<img src="{{ field_product_images }}"
srcset="{{ field_product_images }} 735w,{{ field_product_images_1 }} 343w,{{ field_product_images_2 }} 210w,{{ field_product_images_3 }} 260w"
alt="{{ field_product_images_4 }}"
sizes="(min-width: 0px) 100vw, (min-width: 769px) 50vw, (min-width: 993px) 25vw"
class="img-responsive">
It renders for the most part. However, the resulting html looks like this:
<img src="/sites/default/files/styles/product_listing_lg/public/products/2017-01/IMG_0196.JPG?itok=pUdgY8n9"
srcset="/sites/default/files/styles/product_listing_lg/public/products/2017-01/IMG_0196.JPG?itok=pUdgY8n9 1w,/sites/default/files/styles/product_listing_md/public/products/2017-01/IMG_0196.JPG?itok=t7jNSmMk 769w,/sites/default/files/styles/product_listing_sm/public/products/2017-01/IMG_0196.JPG?itok=NH8p7qki 993w,/sites/default/files/styles/product_listing_xs/public/products/2017-01/IMG_0196.JPG?itok=feCEjmRl 1201w"
alt="black and gold variegated infinity scarf (wrapped, front)"
sizes=" 993px) 25vw"
class="img-responsive">
sizes attribute in rewrite:
sizes="(min-width: 0px) 100vw, (min-width: 769px) 50vw, (min-width: 993px) 25vw"
sizes attribute output:
sizes=" 993px) 25vw"
I seem to have the same challenge whether I'm rewriting an image field or specifying replacement patterns in a global text area.
I haven't explored any preprocess or twig template options yet. Is this something I need to resolve outside of views UI to prevent the filtering? What's the best way to proceed?