Skip to content

Instantly share code, notes, and snippets.

@damianwajer
Created August 28, 2015 14:09
Show Gist options
  • Select an option

  • Save damianwajer/e6305d04c35d3cea3e37 to your computer and use it in GitHub Desktop.

Select an option

Save damianwajer/e6305d04c35d3cea3e37 to your computer and use it in GitHub Desktop.
[WordPress] Display gallery from Flickr album with simple shortcode
<?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