';
// Check if the [gallery] exist.
if ( $gallery ) {
// Check if the gallery ids exist.
if ( isset( $gallery['ids'] ) ) {
// Get the gallery ids and convert it into array.
$ids = explode( ',', $gallery['ids'] );
// Display the gallery in a cool slideshow on index page.
foreach( $ids as $id ) {
$html .= '
';
$html .= wp_get_attachment_image( $id, $size, false, array( 'class' => 'entry-thumbnail' ) );
$html .= '
';
}
} else {
// If gallery ids not exist, display the beginner gallery markup.
// avoid this, since it'll look bad
// $html = get_post_gallery( get_the_ID() );
// if gallery based on images attached to post (only [gallery] in post content)
// note: in the post content, better to use: [gallery size="large"] or [gallery size="full"]
$srcs = $gallery['src'];
// Display the gallery in a cool slideshow on index page.
foreach( $srcs as $src ) {
$html .= '
';
$html .= '
 . ')
';
$html .= '
';
}
}
// If no [gallery] in post content, get attached images to the post.
} else {
// Set up default arguments.
$defaults = array(
'order' => 'ASC',
'post_type' => 'attachment',
'post_parent' => get_the_ID(),
'post_mime_type' => 'image',
'numberposts' => -1
);
// Retrieves attachments from the post.
$attachments = get_children( apply_filters( 'beginner_gallery_format_args', $defaults ) );
// Check if attachments exist.
if ( $attachments ) {
// Display the attachment images in a cool slideshow on index page.
foreach ( $attachments as $attachment ) {
$html .= '
';
$html .= wp_get_attachment_image( $attachment->ID, $size, false, array( 'class' => 'entry-thumbnail' ) );
$html .= '
';
}
} else {
// if no [gallery] shortcode and has no attachments, bail them out
return;
}
}
// closing wrapper
$html .= '
';
// Return the gallery images.
return $html;
}
endif;
if ( ! function_exists( 'beginner_get_post_format_link_url' ) ) :
/**
* Forked from hybrid_get_the_post_format_url.
* Filters 'get_the_post_format_url' to make for a more robust and back-compatible function. If WP did
* not find a URL, check the post content for one. If nothing is found, return the post permalink.
* Used in Post Format Link
*
* @since 1.0.0
*/
function beginner_get_post_format_link_url( $url = '', $post = null ) {
if ( empty( $url ) ) {
$post = is_null( $post ) ? get_post() : $post;
/* Catch links that are not wrapped in an '
> > ', '' ); ?>