Support SVG in WrapCachedImage?
Wouldn't it make sense to allow SVG files to run through WrapCachedImage? Currently it returns a DEFAULT RECORD when SVG is used as input, but wouldn't it be more useful if it would return a record containing a link?
For now I've made this utility function, maybe it's useful as inspiration. It serves me well so far:
PUBLIC RECORD FUNCTION GetWrappedCachedSVGOrImage(RECORD file, RECORD resizemethod DEFAULTSTO DEFAULT RECORD)
{
IF (NOT RecordExists(file))
RETURN DEFAULT RECORD;
IF (NOT CellExists(file, "mimetype"))
THROW NEW Exception(`Missing cell "mimetype" in record: ${AnyToString(file,'tree')}`);
IF (file.mimetype = "image/svg+xml")
{
RECORD wrapped := WrapBlob(file.data, file.filename);
STRING link := GetCachedFileLink(file);
RETURN CELL[ ...wrapped
, link
, css := `url(${link}) center/cover`
];
}
IF (NOT RecordExists(resizemethod))
THROW NEW Exception(`2nd param "resizemethod" is required for images`);
RETURN WrapCachedImage(file, resizemethod);
}
Same goes for <imgedit>
I guess, would be useful too to allow SVG. Currently when I want an "image or SVG" from the user, I use a <fileedit>
. Which is technically fine, of course, but would be nice to at least have the preview functionality for an SVG.
Edited by Wouter Hendriks