generaxion / axio-starter

Superior WordPress starter theme with modern build tools by Generaxion (previously Aucor Starter). 250+ hours of development over 6 years to make the greatest starting point for WordPress site.
https://axio.generax.io
GNU General Public License v2.0
164 stars 25 forks source link

Aucor_Image::render() - JPG or SVG #39

Closed kauaicreative closed 3 years ago

kauaicreative commented 3 years ago

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?

kauaicreative commented 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...
TeemuSuoranta commented 3 years ago

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.

TeemuSuoranta commented 3 years ago

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.