Created
August 28, 2015 14:09
-
-
Save damianwajer/e6305d04c35d3cea3e37 to your computer and use it in GitHub Desktop.
[WordPress] Display gallery from Flickr album with simple shortcode
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 characters
| <?php | |
| /** | |
| * Flickr Gallery shortcode | |
| * | |
| * @author Damian Wajer | |
| * @param $atts | |
| * @return string | |
| */ | |
| function prefix_flickr_gallery_shortcode( $atts ) { | |
| $a = shortcode_atts( array( | |
| 'id' => '', | |
| 'width' => '640', | |
| 'height' => '480', | |
| 'user' => 'flickr', | |
| ), $atts ); | |
| if ( ! empty( $a['id'] ) ) { | |
| $url = 'https://www.flickr.com/photos/' . esc_attr( $a['user'] ) .'/sets/' . absint( $a['id'] ) .'/player/'; | |
| $output = '<div class="embed-responsive embed-responsive-4by3">'; | |
| $output .= '<iframe class="embed-responsive-item" src="' . esc_url( $url ) .'" width="' . absint( $a['width'] ) . '" height="' . absint( $a['height'] ) . '" frameborder="0" allowfullscreen webkitallowfullscreen mozallowfullscreen oallowfullscreen msallowfullscreen></iframe>'; | |
| $output .= '</div>'; | |
| return $output; | |
| } | |
| } | |
| add_shortcode( 'flickr', 'prefix_flickr_gallery_shortcode' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment