-
-
Save marbaque/2946bcc7886d636d0ea8b3a3570f3a68 to your computer and use it in GitHub Desktop.
Revisions
-
wpscholar revised this gist
Jul 10, 2015 . 1 changed file with 16 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -13,12 +13,25 @@ 'width' => '400', 'height' => '300' ), $atts ); $params = array( 'w' => $atts['width'], 'h' => $atts['height'], ); $url = urlencode( $atts['url'] ); $src = 'http://s.wordpress.com/mshots/v1/' . $url . '?' . http_build_query( $params, null, '&' ); $cache_key = 'snapshot_' . md5( $src ); $data_uri = get_transient( $cache_key ); if ( ! $data_uri ) { $response = wp_remote_get( $src ); if ( 200 === wp_remote_retrieve_response_code( $response ) ) { $image_data = wp_remote_retrieve_body( $response ); if ( $image_data && is_string( $image_data ) ) { $src = $data_uri = 'data:image/jpeg;base64,' . base64_encode( $image_data ); set_transient( $cache_key, $data_uri, DAY_IN_SECONDS ); } } } return '<img src="' . esc_attr( $src ) . '" alt="' . esc_attr( $atts['alt'] ) . '"/>'; } ); -
wpscholar revised this gist
Jul 8, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ * This shortcode will allow you to create a snapshot of a remote website and post it * on your WordPress site. * * [snapshot url="http://www.wordpress.org" alt="WordPress.org" width="400" height="300"] */ add_shortcode( 'snapshot', function ( $atts ) { $atts = shortcode_atts( array( -
wpscholar revised this gist
Jul 7, 2015 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -13,7 +13,10 @@ 'width' => '400', 'height' => '300' ), $atts ); $params = array( 'w' => $atts['width'], 'h' => $atts['height'], ); $url = urlencode( $atts['url'] ); $src = 'http://s.wordpress.com/mshots/v1/' . $url . '?' . http_build_query( $params, null, '&' ); -
wpscholar revised this gist
Jul 7, 2015 . 2 changed files with 21 additions and 19 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,19 +0,0 @@ This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ <?php /** * This shortcode will allow you to create a snapshot of a remote website and post it * on your WordPress site. * * [snapshot url="http://www.wordpress.org" alt="My description" width="400" height="300"] */ add_shortcode( 'snapshot', function ( $atts ) { $atts = shortcode_atts( array( 'alt' => '', 'url' => 'http://www.wordpress.org', 'width' => '400', 'height' => '300' ), $atts ); $params = array( 'w' => $atts['width'], 'h' => $atts['height'] ); $url = urlencode( $atts['url'] ); $src = 'http://s.wordpress.com/mshots/v1/' . $url . '?' . http_build_query( $params, null, '&' ); return '<img src="' . esc_url( $src ) . '" alt="' . esc_attr( $atts['alt'] ) . '"/>'; } ); -
wpscholar renamed this gist
Jun 4, 2013 . 1 changed file with 7 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,11 @@ <?php /** * This shortcode will allow you to create a snapshot of a remote website and post it * on your WordPress site. * * [snap url="http://www.wordpress.org" alt="My description" w="400" h="300"] */ function snap($atts, $content = null) { extract(shortcode_atts(array( "snap" => 'http://s.wordpress.com/mshots/v1/', -
Micah Wood created this gist
Sep 26, 2011 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ /** * This shortcode will allow you to create a snapshot of a remote website and post it * on your WordPress site. * * [snap url="http://www.wordpress.org" alt="My description" w="400" h="300"] */ function snap($atts, $content = null) { extract(shortcode_atts(array( "snap" => 'http://s.wordpress.com/mshots/v1/', "url" => 'http://www.wordpress.org', "alt" => '', "w" => '400', // width "h" => '300' // height ), $atts)); return '<img src="' . $snap . '' . urlencode($url) . '?w=' . $w . '&h=' . $h . '" alt="' . $alt . '"/>'; } add_shortcode("snap", "snap");