BeAPI/acf-svg-icon

Media SVG autoload causes enormous pages

Opened this issue · 3 comments

Rahe commented

Hello,

By default the SVG files from the media library are included into the content body when picker is used.

On some sites, event if the files are not icons properly said, they are added and the Body weight more than 5Mo compressed and 18mo decompressed !
Without it, we are at 200kb max !

Quick soltun that come to my mind
Make the load from the media libray opt-in from the code.

Nicolas,

This is due to the evolution handling the uploaded medias.
Solution possible on display_svg method, ignore file type "media" because we use the URL and not the svg embeded.

			if ( ! is_file( $file['file'] ) || 'media' == $file['type'] ) {
				continue;
			}

Other solution is to always use the url with the # in front of the url for the sprites.
So there will be no other SVG embeding into the page.

To discuss.

First : Quick win with a patch for the HTML page size.

Second : More profound changes for the medias from the attachment pages (use of comment_count), ony use URLs

The first part is in release 2.1.3