Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@11ty/eleventy-img

Package Overview
Dependencies
Maintainers
1
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@11ty/eleventy-img - npm Package Compare versions

Comparing version 1.0.1-beta.1 to 1.1.0

FUNDING.yml

18

generate-html.js

@@ -68,3 +68,5 @@ const DEFAULT_ATTRIBUTES = {

if(entryCount === 1) {
return { "img": attributesWithoutSizes };
return {
"img": attributesWithoutSizes
};
}

@@ -77,4 +79,5 @@

if(entryCount > 1 && !attributes.sizes) {
// Per the HTML specification sizes is required when multiple sources are in srcset
// The default "100vw" is okay
// Per the HTML specification sizes is required srcset is using the `w` unit
// https://html.spec.whatwg.org/dev/semantics.html#the-link-element:attr-link-imagesrcset-4
// Using the default "100vw" is okay
throw new Error(missingSizesErrorMessage);

@@ -88,3 +91,5 @@ }

return { "img": imgAttributes };
return {
img: imgAttributes
};
}

@@ -97,4 +102,5 @@

if(imageFormat.length > 1 && !attributes.sizes) {
// Per the HTML specification sizes is required when multiple sources are in srcset
// The default "100vw" is okay
// Per the HTML specification sizes is required srcset is using the `w` unit
// https://html.spec.whatwg.org/dev/semantics.html#the-link-element:attr-link-imagesrcset-4
// Using the default "100vw" is okay
throw new Error(missingSizesErrorMessage);

@@ -101,0 +107,0 @@ }

@@ -96,7 +96,14 @@ const path = require("path");

static isFullUrl(url) {
static isRemoteUrl(url) {
try {
new URL(url);
return true;
} catch(e) {
const validUrl = new URL(url);
if (validUrl.protocol.startsWith("https:") || validUrl.protocol.startsWith("http:")) {
return true;
}
return false;
} catch(e)
{
// invalid url OR local path

@@ -108,2 +115,5 @@ return false;

// Temporary alias for changes made in https://github.com/11ty/eleventy-img/pull/138
Util.isFullUrl = Util.isRemoteUrl;
class Image {

@@ -116,3 +126,3 @@ constructor(src, options) {

this.src = src;
this.isRemoteUrl = typeof src === "string" && Util.isFullUrl(src);
this.isRemoteUrl = typeof src === "string" && Util.isRemoteUrl(src);
this.options = Object.assign({}, globalOptions, options);

@@ -378,2 +388,8 @@

// https://jdhao.github.io/2019/07/31/image_rotation_exif_info/
// Orientation 5 to 8 means image is rotated (width/height are flipped)
needsRotation(orientation) {
return orientation >= 5;
}
// metadata so far: width, height, format

@@ -385,2 +401,9 @@ // src is used to calculate the output file names

if (this.needsRotation(metadata.orientation)) {
let height = metadata.height;
let width = metadata.width;
metadata.width = height;
metadata.height = width;
}
for(let outputFormat of outputFormats) {

@@ -456,3 +479,10 @@ if(!outputFormat || outputFormat === "auto") {

}
if(this.needsRotation(metadata.orientation)) {
sharpInstance.rotate();
}
sharpInstance.resize(resizeOptions);
} else if (stat.width === metadata.width && metadata.format !== "svg") {
if(this.needsRotation(metadata.orientation)) {
sharpInstance.rotate();
}
}

@@ -515,4 +545,4 @@

static statsSync(src, opts) {
if(typeof src === "string" && Util.isFullUrl(src)) {
throw new Error("`statsSync` is not supported with full URL sources. Use `statsByDimensionsSync` instead.");
if(typeof src === "string" && Util.isRemoteUrl(src)) {
throw new Error("`statsSync` is not supported with remote sources. Use `statsByDimensionsSync` instead.");
}

@@ -596,3 +626,3 @@

if(typeof src === "string" && opts && opts.statsOnly) {
if(Util.isFullUrl(src)) {
if(Util.isRemoteUrl(src)) {
if(!opts.remoteImageMetadata || !opts.remoteImageMetadata.width || !opts.remoteImageMetadata.height) {

@@ -599,0 +629,0 @@ throw new Error("When using `statsOnly` and remote images, you must supply a `remoteImageMetadata` object with { width, height, format? }");

{
"name": "@11ty/eleventy-img",
"version": "1.0.1-beta.1",
"version": "1.1.0",
"description": "Low level utility to perform build-time image transformations.",

@@ -41,9 +41,9 @@ "publishConfig": {

"base64url": "^3.0.1",
"image-size": "^1.0.0",
"image-size": "^1.0.1",
"p-queue": "^6.6.2",
"sharp": "^0.29.3"
"sharp": "^0.30.1"
},
"devDependencies": {
"ava": "^3.15.0",
"eslint": "^8.6.0"
"ava": "^4.0.1",
"eslint": "^8.9.0"
},

@@ -50,0 +50,0 @@ "ava": {

@@ -35,1 +35,7 @@ <p align="center"><img src="https://www.11ty.dev/img/logo-github.png" alt="eleventy Logo"></p>

- ℹ️ To keep tests fast, thou shalt try to avoid writing files in tests.
## Community Roadmap
- [Top Feature Requests](https://github.com/11ty/eleventy-img/issues?q=label%3Aneeds-votes+sort%3Areactions-%2B1-desc+label%3Aenhancement) (Add your own votes using the 👍 reaction)
- [Top Bugs 😱](https://github.com/11ty/eleventy-img/issues?q=is%3Aissue+is%3Aopen+label%3Abug+sort%3Areactions-%2B1-desc) (Add your own votes using the 👍 reaction)
- [Newest Bugs 🙀](https://github.com/11ty/eleventy-img/issues?q=is%3Aopen+is%3Aissue+label%3Abug)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc