Skip to content

Support data-srcset#193

Description

@bouiboui

Hi! 馃憢

Firstly, thanks for your work on this project! 馃檪

Today I used patch-package to patch html2amp@1.4.2 for the project I'm working on.

I don't think it's a perfect solution but it might help someone else.

Here is the diff that solved my problem:

diff --git a/node_modules/html2amp/lib/utils.js b/node_modules/html2amp/lib/utils.js
index e17e685..a67a513 100644
--- a/node_modules/html2amp/lib/utils.js
+++ b/node_modules/html2amp/lib/utils.js
@@ -51,7 +51,7 @@ const normalizeSrc = (src, srcset) => {
 const remoteImgCaches = new Map()
 const srcNode = async (cwd, attributes) => {
   const { src, alt = '', ...attrs } = attributes
-  const url = normalizeUrl(normalizeSrc(src, attributes.srcset))
+  const url = normalizeUrl(normalizeSrc(src, attributes.srcset || attributes['data-srcset']))
   let size = { width: null, height: null }
   let result = null
   if (url.startsWith('http')) {

This issue body was partially generated by patch-package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions