Lofesa commented on issue #1899: data-srcset in img and amp-img
URL: 
https://github.com/apache/incubator-pagespeed-mod/pull/1899#issuecomment-508607206
 
 
   Hi @oschaaf
   I think the loop is needed or we need a double if w/o the else if. Why? 
Think in an img element, this may have this structure:
   <img width="1280" height="720" 
src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"
 class="attachment-full size-full wp-post-image lazyload" alt="Reformas 
Laborales" itemprop="image" 
**srcset**="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
 1280w**" sizes="(max-width: 1280px) 100vw, 1280px" 
**data-srcset**="https://intersindicalrm.org/wp-content/uploads/2019/06/xderogar-reformas-laborales-aprobadas-en-la-crisis.jpg.pagespeed.ic.3uh3s3phk-.webp
 1280w, 
https://intersindicalrm.org/wp-content/uploads/2019/06/xderogar-reformas-laborales-aprobadas-en-la-crisis-150x84.jpg.pagespeed.ic.d4ruf5x8pB.webp
 150w, 
https://intersindicalrm.org/wp-content/uploads/2019/06/xderogar-reformas-laborales-aprobadas-en-la-crisis-300x169.jpg.pagespeed.ic.9Aevn_bJgv.webp
 300w, 
https://intersindicalrm.org/wp-content/uploads/2019/06/xderogar-reformas-laborales-aprobadas-en-la-crisis-768x432.jpg.pagespeed.ic.CcPsctvZIU.webp
 768w, 
https://intersindicalrm.org/wp-content/uploads/2019/06/xderogar-reformas-laborales-aprobadas-en-la-crisis-600x338.jpg.pagespeed.ic.lfm2n5YL4K.webp
 600w, 
https://intersindicalrm.org/wp-content/uploads/2019/06/xderogar-reformas-laborales-aprobadas-en-la-crisis-200x113.jpg.pagespeed.ic.oOyn7fNPgK.webp
 200w" 
data-src="wp-content/uploads/2019/06/xderogar-reformas-laborales-aprobadas-en-la-crisis.jpg.pagespeed.ic.3uh3s3phk-.webp"
 loading="lazy">
   
   This element have a placeholder srcset set to a data uri (but maybe a url to 
a 1x1 px image) and a data-srcset with the real images. The `if else if` found 
the srcset placeholder and send it to BeginRewriteSrcSet but don´t ask for more 
image valued attributes so the data-srcset can´t be rewrited then we need 2 
`if`, 1 for the srcset and 1 more for the data-srcset.
   
   If the ineficiency is due we call FindAttribute(), maybe we ask for some 
like 
   ```
   if (attributes[i]->keyword() == HtmlName::kDataSrcset) {
       BeginRewriteSrcSet(element, datasrcset);
   } else if (attributes[i]->keyword() == HtmlName::kSrcset) {
      BeginRewriteSrcSet(element, srcset);
   }
   ```
   
   if this is the rigth syntax so we don´t call a external class.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to