Closed kauaicreative closed 3 years ago
Right now I am just modifying the image component backend() with some custom code. But not sure if there is a built in way to handle this.
// svg
if (substr($image['file'], -4) === '.svg') {
$args['attr']['src'] = self::get_image_url($args['id'], 'full');
}
// Responsive
else ... responsive code...
That's a good enhancement as image component probably won't handle SVGs properly at the moment. You are absolutely on the right track and only changes needed are on the backend side to skip the whole responsive markup as there are no image size variations.
We should add built-in support for SVGs also as it is pretty easy to do and needed every now and then. For cleaner solution maybe you wouldn't need to even check the file extension but it would require a bit of research and testing to make sure what metadata does WP save for SVGs. For project code, I think checking SVG extension is just fine.
We could let this ticket be open until there is built-in solution implemented.
SVG support is now implemented in 6.0 branch https://github.com/aucor/aucor-starter/commit/af612cc7ed6d44925f60a61fc00e4bc7aa345687
It seems like some SVG support plugins save meta data for width/height that did work before but there is now support also for SVGs that are missing meta data. You can simply replace the file modified here.
I want to allow a user to select an image - either bitmap or SVG. Of course SVGs do not need responsive handling. So, what is the best strategy to Aucor_Image::render() an image that could be a JPG or SVG?