{"id":15016566,"url":"https://github.com/luwes/eleventy-plugin-sharp","last_synced_at":"2025-06-27T10:06:58.634Z","repository":{"id":42704645,"uuid":"291466360","full_name":"luwes/eleventy-plugin-sharp","owner":"luwes","description":"Eleventy plugin wielding Sharp's image processing power to the fullest.","archived":false,"fork":false,"pushed_at":"2023-11-16T18:32:40.000Z","size":65,"stargazers_count":18,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-27T10:05:54.764Z","etag":null,"topics":["11ty","eleventy","sharp"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/luwes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-30T12:30:02.000Z","updated_at":"2023-11-25T01:09:06.000Z","dependencies_parsed_at":"2024-12-20T00:12:07.908Z","dependency_job_id":"3ddb4710-44f4-4681-a92e-89cb194304df","html_url":"https://github.com/luwes/eleventy-plugin-sharp","commit_stats":{"total_commits":12,"total_committers":3,"mean_commits":4.0,"dds":"0.16666666666666663","last_synced_commit":"5e290f50a857d84e3180cb4838350668e2473c68"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/luwes/eleventy-plugin-sharp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luwes%2Feleventy-plugin-sharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luwes%2Feleventy-plugin-sharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luwes%2Feleventy-plugin-sharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luwes%2Feleventy-plugin-sharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luwes","download_url":"https://codeload.github.com/luwes/eleventy-plugin-sharp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luwes%2Feleventy-plugin-sharp/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262235779,"owners_count":23279566,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["11ty","eleventy","sharp"],"created_at":"2024-09-24T19:49:05.201Z","updated_at":"2025-06-27T10:06:58.567Z","avatar_url":"https://github.com/luwes.png","language":"JavaScript","readme":"# eleventy-plugin-sharp\n\n**npm**: `npm i eleventy-plugin-sharp`  \n\nInspired by the [Craft CMS image transform API](https://craftcms.com/docs/3.x/image-transforms.html).  \nThis plugin gives you the full power of the awesome [sharp](https://sharp.pixelplumbing.com/) library in your [11ty](https://www.11ty.dev/) templates.\n\n\n## Usage\n\n```js\n// .eleventy.js\nconst sharpPlugin = require('eleventy-plugin-sharp');\n\nmodule.exports = function (eleventyConfig) {\n  eleventyConfig.addPlugin(sharpPlugin({\n    urlPath: '/images',\n    outputDir: 'public/images'\n  }));\n};\n```\n\n\n## Filters\n\nFilters are used to build up the Sharp instance. Pretty much all the methods that the [Sharp API](https://sharp.pixelplumbing.com/api-constructor) provides can be called. [`output options`](https://sharp.pixelplumbing.com/api-output), [`resizing`](https://sharp.pixelplumbing.com/api-resize), [`operations`](https://sharp.pixelplumbing.com/api-operation), [`colour`](https://sharp.pixelplumbing.com/api-colour), etc.\n\n\n## Shortcodes\n\nIn addition shortcodes are used to execute the async functions of Sharp, something filters don't support.\n\n- `getUrl(instanceOrFilepath)` Saves the image to disk and gets the url.\n- `getWidth(instanceOrFilepath)` Gets the width of an image.\n- `getHeight(instanceOrFilepath)` Gets the height of an image.\n- `getMetadata(instanceOrFilepath)` Gets the metadata of an image.\n- `getStats(instanceOrFilepath)` Gets the stats of an image.\n\n\n## Responsive images using `\u003cpicture\u003e`\n\nThe `sharp` filter is optional if the input file is followed by any Sharp transform.\n\n```njk\n{% set image = \"src/images/zen-pond.jpg\" | sharp %}\n\n\u003cpicture\u003e\n  \u003csource srcset=\"{% getUrl image | resize({ width: 1440, height: 460 }) | webp %} 1x, {% getUrl image | resize({ width: 2560, height: 800 }) | webp %} 2x\" media=\"(min-width: 640px)\"\u003e\n  \u003csource srcset=\"{% getUrl image | resize({ width: 640, height: 320 }) | webp %} 1x, {% getUrl image | resize({ width: 1280, height: 640 }) | webp %} 2x\"\u003e\n  \u003csource srcset=\"{% getUrl image | resize({ width: 1440, height: 460 }) %} 1x, {% getUrl image | resize({ width: 2560, height: 800 }) %} 2x\" media=\"(min-width: 640px)\"\u003e\n  \u003cimg class=\"articleHero-image\" srcset=\"{% getUrl image | resize({ width: 640, height: 320 }) %} 1x, {% getUrl image | resize({ width: 1280, height: 640 }) %} 2x\" alt=\"{{ image.title }}\"\u003e\n\u003c/picture\u003e\n```\n\n\n## Get the dimensions of a saved image w/ custom output filepath\n\n```njk\n{% set bannerImage = \"src/images/zen-pond.jpg\" | resize(1440, 460) | toFile(\"public/images/custom-name.webp\") %}\n\n{% getUrl bannerImage %}\n{% getWidth bannerImage.fileOut %}\n{% getHeight bannerImage.fileOut %}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluwes%2Feleventy-plugin-sharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluwes%2Feleventy-plugin-sharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluwes%2Feleventy-plugin-sharp/lists"}