From 9599dd9705009d9eb71e30cf34abffbfe6303dca Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 27 May 2014 10:54:54 +0000 Subject: [PATCH] Avoid a PHP notice in bundled themes if no images were found. props nabil_kadimi. fixes #28361. git-svn-id: https://develop.svn.wordpress.org/trunk@28585 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-content/themes/twentyeleven/image.php | 3 ++- src/wp-content/themes/twentyten/loop-attachment.php | 3 ++- src/wp-content/themes/twentytwelve/image.php | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/wp-content/themes/twentyeleven/image.php b/src/wp-content/themes/twentyeleven/image.php index 74228dbdbf..7516b034c8 100644 --- a/src/wp-content/themes/twentyeleven/image.php +++ b/src/wp-content/themes/twentyeleven/image.php @@ -57,9 +57,10 @@ get_header(); ?> if ( $attachment->ID == $post->ID ) break; } - $k++; + // If there is more than 1 attachment in a gallery if ( count( $attachments ) > 1 ) { + $k++; if ( isset( $attachments[ $k ] ) ) // get the URL of the next image attachment $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID ); diff --git a/src/wp-content/themes/twentyten/loop-attachment.php b/src/wp-content/themes/twentyten/loop-attachment.php index 3976b0d6e8..26e213eec0 100644 --- a/src/wp-content/themes/twentyten/loop-attachment.php +++ b/src/wp-content/themes/twentyten/loop-attachment.php @@ -71,9 +71,10 @@ if ( $attachment->ID == $post->ID ) break; } - $k++; + // If there is more than 1 image attachment in a gallery if ( count( $attachments ) > 1 ) { + $k++; if ( isset( $attachments[ $k ] ) ) // get the URL of the next image attachment $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID ); diff --git a/src/wp-content/themes/twentytwelve/image.php b/src/wp-content/themes/twentytwelve/image.php index 285e453c71..1dc2aa9312 100644 --- a/src/wp-content/themes/twentytwelve/image.php +++ b/src/wp-content/themes/twentytwelve/image.php @@ -58,9 +58,9 @@ foreach ( $attachments as $k => $attachment ) : break; endforeach; -$k++; // If there is more than 1 attachment in a gallery if ( count( $attachments ) > 1 ) : + $k++; if ( isset( $attachments[ $k ] ) ) : // get the URL of the next image attachment $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID );