WU SVG Icons[Solution]
-
I tried to use SVG icons with the widget and I found a way to do it. With SVG files the weather widget looks crisp in high resolution displays and modern smartphones. If you want to do it follow the following steps:
1-From the WU webpage inspect the forecast image to discover the icons directory, the result is:
“//icons.wxug.com/i/c/v4/”. Save that path for later. (Note the missing “http:”)2-Edit the function.php file from your theme and add this at the end of the file (use the path without the “htpp:”):
//Add Retina icons(SVG) to Weather Underground Widget add_filter('wp_wunderground_forecast_icon', 'use_custom_wunderground_icons', 10, 2 ); /** * @return string URL to the root folder of the icon set. */ function use_custom_wunderground_icons( $url_base = '', $icon_name = '' ) { return '//icons.wxug.com/i/c/v4/'; }
You can vary the “v4” part for your choose from v1 to v4. All these includes SVG icons.
3-In the file “icon.html” in the path “plugin/wunderground/templates/snippets/”, change the extension in {{icon}}.gif for {{icon}}.svg as follow:
<{{tag}} class="wu-icon"><img src="{{user_icon_url}}/{{icon}}.svg" alt="{{ forecast.condition ? forecast.condition|e : day.condition|e }}" width="{{iconsize}}" height="{{iconsize}}" /></{{tag}}>
- The topic ‘WU SVG Icons[Solution]’ is closed to new replies.