{"id":10127996,"date":"2018-03-29T13:14:59","date_gmt":"2018-03-29T13:14:59","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/duplicate-code-and-a-feature-request\/"},"modified":"2018-03-29T13:14:59","modified_gmt":"2018-03-29T13:14:59","slug":"duplicate-code-and-a-feature-request","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/duplicate-code-and-a-feature-request\/","title":{"rendered":"Duplicate code and a feature request"},"content":{"rendered":"<p>Trying to have my site not to serve mixed content under certain CDN provider&#8217;s Flexible SSL (successful result included in the code snippet below) I discovered that you seem to have a duplicated code in your plugin:<\/p>\n<pre><code>...\n\/\/ Remove sizes and srcset attribute.\n$img-&gt;removeAttribute( &#039;sizes&#039; );\n$img-&gt;removeAttribute( &#039;srcset&#039; );\n\n\/\/ TODO: add &quot;} \/\/ End if().&quot; and delete everything below until next TODO\n\/\/ Get src value.\n$src = $img-&gt;getAttribute( &#039;src&#039; );\n\n\/\/ Check if we have a src.\nif ( &#039;&#039; === $src ) {\n\/\/ Set the value from data-noscript as src.\n$src = $img-&gt;getAttribute( &#039;data-noscript&#039; );\n} \/\/ End if().\n\n\/\/ Set data-src value.\n$img-&gt;setAttribute( &#039;data-src&#039;, $src );\n} else {\n\/\/ TODO: Stop here\n\/\/ Get src attribute.\n$src = $img-&gt;getAttribute( &#039;src&#039; );\n\/\/ TODO: Review new optional code: stripping HTTP and HTTPS from src URLs\n\/\/ or could you even maybe make it toggleable via checkbox in admin panel?\n$src = str_replace([&#039;http:&#039;, &#039;https:&#039;], &#039;&#039;, $src);\n\t\t\t\n\t\t\t\/\/ Check if we do not have a value.\n\t\t\tif ( &#039;&#039; === $src ) {\n\t\t\t\t\/\/ Set the value from data-noscript as src.\n\t\t\t\t$src = $img-&gt;getAttribute( &#039;data-noscript&#039; );\n\t\t\t} \/\/ End if().\n\n\t\t\t\/\/ Set data-src value.\n\t\t\t$img-&gt;setAttribute( &#039;data-src&#039;, $src );\n\/\/ TODO: Delete the line below too.\n}\/\/ End if().\n<\/code><\/pre>\n<p>I would be happy to be proven wrong, but after my changes everything works as it did before, so consider it both a minor bug report and a minor feature request.<\/p>\n","protected":false},"template":"","class_list":["post-10127996","topic","type-topic","status-publish","hentry","topic-tag-minor-bug"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/10127996","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/10127996\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=10127996"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}