yum-slop/yummers.dev
source code for https://yummers.dev
git clone https://git.yummers.dev/yum-slop/yummers.dev
49b768a
master
1-- Add intrinsic dimensions to images that do not already specify them. 2-- This reserves their layout space before the browser has loaded the file. 3function Image ( image ) 4if image . attributes . width or image . attributes . height then 5return image 6end 7 8local ok , mime_type , contents =pcall ( pandoc . mediabag . fetch , image . src ) 9if not ok or not contents then 10return image 11end 12 13local sized , dimensions =pcall ( pandoc . image . size , contents ) 14if not sized then 15return image 16end 17 18image . attributes . width =tostring ( math . floor ( dimensions . width + 0.5 )) 19image . attributes . height =tostring ( math . floor ( dimensions . height + 0.5 )) 20return image 21end