Created
July 19, 2018 06:15
-
-
Save humayunahmed8/249c5f1fbe9e2efa14acd9170798bffe to your computer and use it in GitHub Desktop.
Google Maps Shortcode (Static)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function crazyland_maps_shortcode($atts) { | |
$default = array( | |
'lat' => '22.9196383', | |
'lon' => '91.520781', | |
'zoom' => '16', | |
'width' => '600', | |
'height' => '400', | |
); | |
$map_data = shortcode_atts( $default, $atts); | |
$img = '<img src="http://maps.google.com/maps/api/staticmap?center=%f,%f&zoom=%d&size=%dx%d" />'; | |
return sprintf($img,$map_data['lat'],$map_data['lon'],$map_data['zoom'],$map_data['width'],$map_data['height']); | |
} | |
add_shortcode( 'maps', 'crazyland_maps_shortcode'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment