You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So, I'd like to keep images seperated by collectionGlob. Each collection has an image folder. When calling a nunjucks plugin to process the image, I'd like it to tell the folder path + src. That I would like to come from a folder data file either json or js. Just unsure how to go about doing it?
in _11ty/image.js
const Image = require("@11ty/eleventy-img");
const path = require("path");
const fs = require("fs");
module.exports = function(src, alt, widths, sizes, classattr) {
// src input same as 'normal' site-relative path for convenience, so add base path:
src = collectionpath + src;
let ext = src.substr(src.lastIndexOf(".") + 1);
let currentFormat = ext == "png" ? "png" : "jpeg";
let srcset = [100, 320, 640, 1024, 1536, 2048];
if (widths) {
widthsArray = widths.split(",");
srcset = widthsArray.map(n => Number(n));
}
let options = {
urlPath: collectionpath,
outputDir: collectionpath,
One of the collection folders has foldername.11tydata.js
So, I need to tell image.js to LOOK in the folder and read the 11tydata and establish what the path variable will be to create the image. Haven't figured out cache yet.
The text was updated successfully, but these errors were encountered:
inetbiz
changed the title
Getting image path from 11tydata in a folder
Getting image path from 11tydata in a folder for 11ty image plugin
Apr 16, 2022
So, I'd like to keep images seperated by collectionGlob. Each collection has an image folder. When calling a nunjucks plugin to process the image, I'd like it to tell the folder path + src. That I would like to come from a folder data file either json or js. Just unsure how to go about doing it?
in
_11ty/image.js
One of the collection folders has foldername.11tydata.js
So, I need to tell image.js to LOOK in the folder and read the 11tydata and establish what the path variable will be to create the image. Haven't figured out cache yet.
The text was updated successfully, but these errors were encountered: