forked from mirror/_s
Merge pull request #339 from obenland/image.php
Remove `image.php` and related code.
This commit is contained in:
commit
aa0879e054
|
@ -83,9 +83,6 @@ function _s_scripts() {
|
||||||
|
|
||||||
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) )
|
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) )
|
||||||
wp_enqueue_script( 'comment-reply' );
|
wp_enqueue_script( 'comment-reply' );
|
||||||
|
|
||||||
if ( is_singular() && wp_attachment_is_image() )
|
|
||||||
wp_enqueue_script( '_s-keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20120202' );
|
|
||||||
}
|
}
|
||||||
add_action( 'wp_enqueue_scripts', '_s_scripts' );
|
add_action( 'wp_enqueue_scripts', '_s_scripts' );
|
||||||
|
|
||||||
|
|
78
image.php
78
image.php
|
@ -1,78 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* The template for displaying image attachments.
|
|
||||||
*
|
|
||||||
* @package _s
|
|
||||||
*/
|
|
||||||
|
|
||||||
get_header(); ?>
|
|
||||||
|
|
||||||
<div id="primary" class="content-area image-attachment">
|
|
||||||
<main id="main" class="site-main" role="main">
|
|
||||||
|
|
||||||
<?php while ( have_posts() ) : the_post(); ?>
|
|
||||||
|
|
||||||
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
|
|
||||||
<header class="entry-header">
|
|
||||||
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
|
|
||||||
|
|
||||||
<div class="entry-meta">
|
|
||||||
<?php
|
|
||||||
$metadata = wp_get_attachment_metadata();
|
|
||||||
printf( __( 'Published <span class="entry-date"><time class="entry-date" datetime="%1$s">%2$s</time></span> at <a href="%3$s">%4$s × %5$s</a> in <a href="%6$s" rel="gallery">%7$s</a>', '_s' ),
|
|
||||||
esc_attr( get_the_date( 'c' ) ),
|
|
||||||
esc_html( get_the_date() ),
|
|
||||||
esc_url( wp_get_attachment_url() ),
|
|
||||||
$metadata['width'],
|
|
||||||
$metadata['height'],
|
|
||||||
esc_url( get_permalink( $post->post_parent ) ),
|
|
||||||
get_the_title( $post->post_parent )
|
|
||||||
);
|
|
||||||
|
|
||||||
edit_post_link( __( 'Edit', '_s' ), '<span class="edit-link">', '</span>' );
|
|
||||||
?>
|
|
||||||
</div><!-- .entry-meta -->
|
|
||||||
|
|
||||||
<nav role="navigation" id="image-navigation" class="image-navigation">
|
|
||||||
<div class="nav-previous"><?php previous_image_link( false, __( '<span class="meta-nav">←</span> Previous', '_s' ) ); ?></div>
|
|
||||||
<div class="nav-next"><?php next_image_link( false, __( 'Next <span class="meta-nav">→</span>', '_s' ) ); ?></div>
|
|
||||||
</nav><!-- #image-navigation -->
|
|
||||||
</header><!-- .entry-header -->
|
|
||||||
|
|
||||||
<div class="entry-content">
|
|
||||||
<div class="entry-attachment">
|
|
||||||
<div class="attachment">
|
|
||||||
<?php _s_the_attached_image(); ?>
|
|
||||||
</div><!-- .attachment -->
|
|
||||||
|
|
||||||
<?php if ( has_excerpt() ) : ?>
|
|
||||||
<div class="entry-caption">
|
|
||||||
<?php the_excerpt(); ?>
|
|
||||||
</div><!-- .entry-caption -->
|
|
||||||
<?php endif; ?>
|
|
||||||
</div><!-- .entry-attachment -->
|
|
||||||
|
|
||||||
<?php
|
|
||||||
the_content();
|
|
||||||
wp_link_pages( array(
|
|
||||||
'before' => '<div class="page-links">' . __( 'Pages:', '_s' ),
|
|
||||||
'after' => '</div>',
|
|
||||||
) );
|
|
||||||
?>
|
|
||||||
</div><!-- .entry-content -->
|
|
||||||
|
|
||||||
<?php edit_post_link( __( 'Edit', '_s' ), '<footer class="entry-meta"><span class="edit-link">', '</span></footer>' ); ?>
|
|
||||||
</article><!-- #post-## -->
|
|
||||||
|
|
||||||
<?php
|
|
||||||
// If comments are open or we have at least one comment, load up the comment template
|
|
||||||
if ( comments_open() || '0' != get_comments_number() )
|
|
||||||
comments_template();
|
|
||||||
?>
|
|
||||||
|
|
||||||
<?php endwhile; // end of the loop. ?>
|
|
||||||
|
|
||||||
</main><!-- #main -->
|
|
||||||
</div><!-- #primary -->
|
|
||||||
|
|
||||||
<?php get_footer(); ?>
|
|
|
@ -34,22 +34,6 @@ function _s_body_classes( $classes ) {
|
||||||
}
|
}
|
||||||
add_filter( 'body_class', '_s_body_classes' );
|
add_filter( 'body_class', '_s_body_classes' );
|
||||||
|
|
||||||
/**
|
|
||||||
* Filter in a link to a content ID attribute for the next/previous image links
|
|
||||||
* on image attachment pages.
|
|
||||||
*/
|
|
||||||
function _s_enhanced_image_navigation( $url, $id ) {
|
|
||||||
if ( ! is_attachment() && ! wp_attachment_is_image( $id ) )
|
|
||||||
return $url;
|
|
||||||
|
|
||||||
$image = get_post( $id );
|
|
||||||
if ( ! empty( $image->post_parent ) && $image->post_parent != $id )
|
|
||||||
$url .= '#main';
|
|
||||||
|
|
||||||
return $url;
|
|
||||||
}
|
|
||||||
add_filter( 'attachment_link', '_s_enhanced_image_navigation', 10, 2 );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters wp_title to print a neat <title> tag based on what is being viewed.
|
* Filters wp_title to print a neat <title> tag based on what is being viewed.
|
||||||
*
|
*
|
||||||
|
|
|
@ -115,57 +115,6 @@ function _s_comment( $comment, $args, $depth ) {
|
||||||
}
|
}
|
||||||
endif; // ends check for _s_comment()
|
endif; // ends check for _s_comment()
|
||||||
|
|
||||||
if ( ! function_exists( '_s_the_attached_image' ) ) :
|
|
||||||
/**
|
|
||||||
* Prints the attached image with a link to the next attached image.
|
|
||||||
*/
|
|
||||||
function _s_the_attached_image() {
|
|
||||||
$post = get_post();
|
|
||||||
$attachment_size = apply_filters( '_s_attachment_size', array( 1200, 1200 ) );
|
|
||||||
$next_attachment_url = wp_get_attachment_url();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Grab the IDs of all the image attachments in a gallery so we can get the
|
|
||||||
* URL of the next adjacent image in a gallery, or the first image (if
|
|
||||||
* we're looking at the last image in a gallery), or, in a gallery of one,
|
|
||||||
* just the link to that image file.
|
|
||||||
*/
|
|
||||||
$attachment_ids = get_posts( array(
|
|
||||||
'post_parent' => $post->post_parent,
|
|
||||||
'fields' => 'ids',
|
|
||||||
'numberposts' => -1,
|
|
||||||
'post_status' => 'inherit',
|
|
||||||
'post_type' => 'attachment',
|
|
||||||
'post_mime_type' => 'image',
|
|
||||||
'order' => 'ASC',
|
|
||||||
'orderby' => 'menu_order ID'
|
|
||||||
) );
|
|
||||||
|
|
||||||
// If there is more than 1 attachment in a gallery...
|
|
||||||
if ( count( $attachment_ids ) > 1 ) {
|
|
||||||
foreach ( $attachment_ids as $attachment_id ) {
|
|
||||||
if ( $attachment_id == $post->ID ) {
|
|
||||||
$next_id = current( $attachment_ids );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// get the URL of the next image attachment...
|
|
||||||
if ( $next_id )
|
|
||||||
$next_attachment_url = get_attachment_link( $next_id );
|
|
||||||
|
|
||||||
// or get the URL of the first image attachment.
|
|
||||||
else
|
|
||||||
$next_attachment_url = get_attachment_link( array_shift( $attachment_ids ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
printf( '<a href="%1$s" rel="attachment">%2$s</a>',
|
|
||||||
esc_url( $next_attachment_url ),
|
|
||||||
wp_get_attachment_image( $post->ID, $attachment_size )
|
|
||||||
);
|
|
||||||
}
|
|
||||||
endif;
|
|
||||||
|
|
||||||
if ( ! function_exists( '_s_posted_on' ) ) :
|
if ( ! function_exists( '_s_posted_on' ) ) :
|
||||||
/**
|
/**
|
||||||
* Prints HTML with meta information for the current post-date/time and author.
|
* Prints HTML with meta information for the current post-date/time and author.
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
jQuery( document ).ready( function( $ ) {
|
|
||||||
$( document ).keydown( function( e ) {
|
|
||||||
var url = false;
|
|
||||||
if ( e.which === 37 ) { // Left arrow key code
|
|
||||||
url = $( '.nav-previous a' ).attr( 'href' );
|
|
||||||
}
|
|
||||||
else if ( e.which === 39 ) { // Right arrow key code
|
|
||||||
url = $( '.entry-attachment a' ).attr( 'href' );
|
|
||||||
}
|
|
||||||
if ( url && ( ! $( 'textarea, input' ).is( ':focus' ) ) ) {
|
|
||||||
window.location = url;
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
} );
|
|
Reference in New Issue