Skip to content

[eleventy-plugin-local-respimg] Relative img src #24

@scastiel

Description

@scastiel

Hi, thank you for this plugin it’s truly awesome!

The issue is with relative src attributes for images. If I have this:

<!-- File src/posts/my-post.html -->
<img src="image.png">

With this in 11ty config:

dir: { input: 'src', output: '_site' },

And this in the plugin config:

folders: { source: 'src', output: '_site' },

The files are correctly generated (in _site/posts) but in the resulting HTML, I get references to posts/image***, instead of either image*** or /posts/image***, so the image is not displayed.

I made it work with a dirty workaround, by making generateSrcSet always return an absolute path:

function generateSrcset(sizes, src, type) {
  return sizes.map(s => `/${replaceExt(src, `.${s}.${type}`)} ${s}w`).join(', ');
  //                     ^
}

It goes without saying that this is not a clean way to proceed 😅, but I had to do it to use the plugin…

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions