-
-
Save billerickson/5220a29adf43bbaa6c5f to your computer and use it in GitHub Desktop.
Remember which gallery you came from
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
<?php | |
/** | |
* Gallery Image | |
* | |
* @package BE_Genesis_Child | |
* @since 1.0.0 | |
* @link https://github.com/billerickson/BE-Genesis-Child | |
* @author Bill Erickson <bill@billerickson.net> | |
* @copyright Copyright (c) 2011, Bill Erickson | |
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License | |
* | |
*/ | |
// Remove Things | |
add_filter( 'prepend_attachment', '__return_false' ); | |
remove_action( 'genesis_after_post', 'genesis_get_comments_template' ); | |
remove_action( 'genesis_post_title', 'genesis_do_post_title' ); | |
remove_action( 'genesis_before_post_content', 'genesis_post_info' ); | |
/** | |
* Attachment Content | |
* | |
*/ | |
function be_attachment_content() { | |
global $post; | |
echo '<p class="attachment-navigation">'; | |
previous_image_link( false, '« Previous' ); | |
$all = isset( $_GET['dcf_gallery'] ) ? get_permalink( esc_attr( $_GET['dcf_gallery'] ) ) : get_permalink( $post->post_parent ); | |
echo ' | <a href="' . $all . '">All Photos</a> | '; | |
next_image_link( false, 'Next »' ); | |
echo '</p>'; | |
$image = wp_get_attachment_image_src( get_the_ID(), 'large' ); | |
echo '<p class="attachment"><img src="' . $image[0] . '" /></p>'; | |
} | |
add_action( 'genesis_post_content', 'be_attachment_content', 5 ); | |
/** | |
* Add Gallery Arg to Adjacent Link | |
* | |
*/ | |
function be_previous_gallery_link( $output, $id, $size, $permalink, $icon, $text ) { | |
$id = intval( $id ); | |
$_post = get_post( $id ); | |
if ( empty( $_post ) || ( 'attachment' != $_post->post_type ) || ! $url = wp_get_attachment_url( $_post->ID ) ) | |
return __( 'Missing Attachment' ); | |
if ( $permalink ) | |
$url = get_attachment_link( $_post->ID ); | |
if( isset( $_GET['dcf_gallery'] ) ) | |
$url = add_query_arg( 'dcf_gallery', esc_attr( $_GET['dcf_gallery'] ), $url ); | |
$post_title = esc_attr( $_post->post_title ); | |
if ( $text ) | |
$link_text = $text; | |
elseif ( $size && 'none' != $size ) | |
$link_text = wp_get_attachment_image( $id, $size, $icon ); | |
else | |
$link_text = ''; | |
if ( trim( $link_text ) == '' ) | |
$link_text = $_post->post_title; | |
return '<a href="' . $url . '" title="' . $post_title . '">' . $link_text . '</a>'; | |
} | |
add_filter( 'wp_get_attachment_link', 'be_previous_gallery_link', 10, 6 ); | |
genesis(); |
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
<?php | |
/** | |
* Gallery | |
* | |
* @package BE_Genesis_Child | |
* @since 1.0.0 | |
* @link https://github.com/billerickson/BE-Genesis-Child | |
* @author Bill Erickson <bill@billerickson.net> | |
* @copyright Copyright (c) 2011, Bill Erickson | |
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License | |
* | |
*/ | |
/** | |
* Gallery Images | |
* | |
*/ | |
function be_gallery_images() { | |
$images = get_post_meta( get_the_ID(), 'be_gallery_images', true ); | |
$count = 0; | |
foreach( $images as $image_id ) { | |
$image = wp_get_attachment_image_src( $image_id, 'thumbnail' ); | |
$image = '<img src="'. $image[0] . '" />'; | |
$class = 0 == $count || 0 == $count % 5 ? 'one-fifth first' : 'one-fifth'; | |
echo '<div class="' . $class . '"><a href="' . add_query_arg( 'dcf_gallery', get_the_ID(), get_permalink( $image_id ) ) . '">' . $image . '</a></div>'; | |
$count++; | |
} | |
} | |
add_action( 'genesis_before_post_content', 'be_gallery_images', 20 ); | |
genesis(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment