Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I hyperlink to a full size image? #227

Open
matt-y opened this issue May 3, 2024 · 0 comments
Open

How can I hyperlink to a full size image? #227

matt-y opened this issue May 3, 2024 · 0 comments

Comments

@matt-y
Copy link

matt-y commented May 3, 2024

Hello I am using the 11ty base template which defines the image short code as follows:

eleventyConfig.addAsyncShortcode("image", async function imageShortcode(src, alt, widths, sizes) {
		// Full list of formats here: https://www.11ty.dev/docs/plugins/image/#output-formats
		// Warning: Avif can be resource-intensive so take care!
		let formats = ["avif", "webp", "auto"];
		let input;
		if(isFullUrl(src)) {
			  input = src;
		} else {
			  input = relativeToInputPath(this.page.inputPath, src);
		}

		let metadata = await eleventyImage(input, {
			  widths: widths || ["auto"],
			  formats,
			  outputDir: path.join(eleventyConfig.dir.output, "img"), // Advanced usage note: `eleventyConfig.dir` works here because we’re using addPlugin.
		});

		// TODO loading=eager and fetchpriority=high
		let imageAttributes = {
			  alt,
			  sizes,
			  loading: "lazy",
			  decoding: "async",
		};

		return eleventyImage.generateHTML(metadata, imageAttributes);
});

I am using the shortcode like so:

{% image "./my-image.jpg", "Alt text" %}

What is the shortest way to get this image to display at a smaller size but hyperlink to the full size? Modifying the default value of ["auto"] for the width field in the default site's image shortcode implementation I am seeing the 600px image used in the generated blog post. However, I still have the full size image I'd like to link to. Is there a way to do this out of the box?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant