I’m looking for the best solution to dynamically change some images extension (from .svg to .png) only if the browser is IE.
I don’t know what’s the best solution :
- parse the html code with PHP
-
use jQuery with something like
$(“img.svg2png”).attr(“src”, …);
-
dealing with htaccess and rewrite rules
- other solution ?
Thanks !
You’re not revealing many details about what you’re doing, but the mod_rewrite solution (catching the
USER_AGENTvariable and checking whether it is IE, and redirecting internally to the matching.pngfile) sounds the most elegant to me, because it works sans JavaScript, and you can keep the file extension. The.svgextension should be meaningless as long as the rightContent-Typeheader is sent.