Add ContentDB image

This commit is contained in:
Starbeamrainbowlabs 2021-06-19 18:14:23 +01:00
parent 1dcfc22f7a
commit 5362c8956e
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
3 changed files with 13 additions and 2 deletions

View file

@ -12,6 +12,14 @@ const image_filename_format = (_id, src, width, format, _options) => {
return `${name}-${width}w.${format}`;
};
function image_metadata_log(metadata, source) {
for(let format in metadata) {
for(let img of metadata[format]) {
console.log(`${source.padEnd(10)} ${format.padEnd(5)} ${`${img.width}x${img.height}`.padEnd(10)} ${img.outputPath}`);
}
}
}
async function shortcode_image(src, alt, classes = "") {
let metadata = await Image(src, {
widths: [300, null],
@ -19,7 +27,7 @@ async function shortcode_image(src, alt, classes = "") {
outputDir: `./_site/img/`,
filenameFormat: image_filename_format
});
console.log(metadata);
image_metadata_log(metadata, `IMAGE`);
let imageAttributes = {
class: classes,
@ -40,7 +48,7 @@ async function shortcode_image_url(src) {
outputDir: `./_site/img/`,
filenameFormat: image_filename_format
});
console.log(metadata);
image_metadata_log(metadata, `IMAGE_URL`);
let data = metadata.jpeg[metadata.jpeg.length - 1];
return data.url;
@ -76,6 +84,7 @@ module.exports = function(eleventyConfig) {
eleventyConfig.addJavaScriptFunction("image", shortcode_image);
// eleventyConfig.addNunjucksAsyncShortcode("image_url", shortcode_image_url);
eleventyConfig.addAsyncShortcode("image_url", shortcode_image_url);
eleventyConfig.addAsyncShortcode("image_urlpass", shortcode_image_urlpass);
eleventyConfig.addNunjucksAsyncShortcode("image_urlpass", shortcode_image_urlpass);
eleventyConfig.addPairedShortcode("gallerybox", shortcode_gallerybox);
}

BIN
.docs/images/contentdb.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

View file

@ -76,6 +76,8 @@ date: 2000-01-01
<div class="features-item wide text-centre">
<h3>ContentDB</h3>
<p><a href="https://content.minetest.net/packages/Starbeamrainbowlabs/worldeditadditions/"><img class="icon-medium" src="{% image_urlpass 'images/contentdb.png' %}" alt="" /></a></p>
<p>Download from ContentDB, or from the <em>Content</em> tab in Minetest.</p>
<p><a class="bigbutton" href="https://content.minetest.net/packages/Starbeamrainbowlabs/worldeditadditions/">WorldEditAdditions on ContentDB</a></p>