Merge branch 'develop'

This commit is contained in:
Robin Cornett
2014-09-27 11:04:07 -04:00
8 changed files with 128 additions and 11 deletions
+6
View File
@@ -76,7 +76,13 @@ Additionally/alternatively, you could set a max-height for the backstretch image
## Changelog
###1.1.2
* plugin properly deactivates if Genesis isn't running
###1.1.1
* corrected XHTML hooks
###1.1.0
* added a setting in the admin to optionally reduce the height of the backstretch image
* refactoring
+1 -1
View File
@@ -12,7 +12,7 @@
* Plugin Name: Display Featured Image for Genesis
* Plugin URI: http://github.com/robincornett/display-featured-image-genesis/
* Description: This plugin requires the Genesis Framework. It varies the display of the post or page featured image, depending on size.
* Version: 1.1.0
* Version: 1.1.2
* Author: Robin Cornett
* Author URI: http://robincornett.com
* License: GPL-2.0+
@@ -18,7 +18,7 @@ class Display_Featured_Image_Genesis_Output {
$item = new stdClass();
global $post;
if ( is_home() ) {
$postspage = get_option( 'page_for_posts' );
$postspage = get_option( 'page_for_posts' );
$item->original = wp_get_attachment_image_src( get_post_thumbnail_id( $postspage ), 'original' );
}
else {
@@ -113,7 +113,8 @@ class Display_Featured_Image_Genesis_Output {
add_action( 'genesis_after_header', array( $this, 'do_backstretch_image' ) );
}
elseif ( ( $item->original[1] <= $item->large ) && ( $item->original[1] > $item->medium ) ) {
add_action( 'genesis_before_entry', array( $this, 'do_large_image' ) );
add_action( 'genesis_before_entry', array( $this, 'do_large_image' ) ); // HTML5
add_action( 'genesis_before_post', array( $this, 'do_large_image' ) ); // XHTML
}
}
@@ -130,7 +131,8 @@ class Display_Featured_Image_Genesis_Output {
$item = $this->get_image_variables();
if ( ! is_home() ) {
remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
remove_action( 'genesis_entry_header', 'genesis_do_post_title' ); // HTML5
remove_action( 'genesis_post_title', 'genesis_do_post_title' ); // XHTML
}
echo '<div class="big-leader"><div class="wrap">';
@@ -153,7 +155,7 @@ class Display_Featured_Image_Genesis_Output {
*/
public function do_large_image() {
global $post;
echo get_the_post_thumbnail( $post->ID, 'large', array( 'class' => 'aligncenter', 'alt' => the_title_attribute( 'echo=0' ) ) );
echo get_the_post_thumbnail( $post->ID, 'large', array( 'class' => 'aligncenter featured', 'alt' => the_title_attribute( 'echo=0' ) ) );
}
}
+30 -5
View File
@@ -22,6 +22,7 @@ class Display_Featured_Image_Genesis {
public function run() {
if ( basename( get_template_directory() ) !== 'genesis' ) {
add_action( 'admin_init', array( $this, 'deactivate' ) );
add_action( 'admin_notices', array( $this, 'error_message' ) );
return;
}
@@ -32,17 +33,41 @@ class Display_Featured_Image_Genesis {
add_filter( 'body_class', array( $this->output, 'add_body_class' ) );
}
/**
* deactivates the plugin if Genesis isn't running
*
* @since 1.1.2
*
*/
public function deactivate() {
if ( version_compare( PHP_VERSION, '5.3', '>=' ) ) {
deactivate_plugins( plugin_basename( dirname( __DIR__ ) ) . '/display-featured-image-genesis.php' ); // __DIR__ is a magic constant introduced in PHP 5.3
}
else {
deactivate_plugins( plugin_basename( dirname( dirname( __FILE__ ) ) ) . '/display-featured-image-genesis.php' );
}
}
/**
* Error message if we're not using the Genesis Framework.
*
* @since 1.1.0
*/
public function error_message() {
echo '<div class="error"><p>' . sprintf(
__( 'Sorry, Display Featured Image for Genesis works only with the Genesis Framework. You can <a href="%1$s">deactivate the plugin</a>, since it is not working anyway, or you can <a href="%2$s">activate a Genesis child theme</a>.', 'display-featured-image-genesis' ),
esc_url( admin_url( 'plugins.php' ) ),
esc_url( admin_url( 'themes.php' ) )
) . '</p></div>';
if ( version_compare( PHP_VERSION, '5.3', '>=' ) ) {
echo '<div class="error"><p>' . sprintf(
__( 'Sorry, Display Featured Image for Genesis works only with the Genesis Framework. It has been deactivated.', 'display-featured-image-genesis' ) ) . '</p></div>';
}
else {
echo '<div class="error"><p>' . sprintf(
__( 'Sorry, Display Featured Image for Genesis works only with the Genesis Framework. It has been deactivated. But since we&#39;re talking anyway, did you know that your server is running PHP version %1$s, which is outdated? You should ask your host to update that for you.', 'display-featured-image-genesis' ),
PHP_VERSION
) . '</p></div>';
}
if ( isset( $_GET['activate'] ) ) {
unset( $_GET['activate'] );
}
}
/**
@@ -15,3 +15,7 @@
left: 0;
text-align: center;
}
img.featured {
max-width: 100%;
}
+1 -1
View File
@@ -1,5 +1,5 @@
jQuery(document).ready(function($) {
$(".big-leader").css({'height':($(window).height())-([BackStretchVars.height])+'px'});
$(".big-leader").backstretch([BackStretchVars.src],{'fade':750,'centeredY':false});
$(".big-leader").backstretch([BackStretchVars.src],{'fade':750});
});
+3
View File
@@ -0,0 +1,3 @@
<?php
// silence is golden
+77
View File
@@ -0,0 +1,77 @@
=== Display Featured Image for Genesis ===
Contributors: littler.chicken
Donate link: https://robincornett.com/donate/
Tags: backstretch, featured image, genesis, studiopress
Requires at least: 3.8
Tested up to: 4.0
Stable tag: 1.1.1
License: GPL-2.0+
License URI: http://www.gnu.org/licenses/gpl-2.0.txt
This plugin works within the Genesis Framework, to display your featured images in beautiful and dynamic ways.
== Description ==
This plugin takes a different approach to how we use and display featured images for posts and pages. Instead of simply reusing an image which already exists in the post/page content, the plugin anticipates that you will want to use lovely large images for your featured images, but to do so intelligently. Depending on what you upload, the plugin will:
* display the image as a _backstretch_ (screen width) image if the image is wider than your site's Large Media Setting.
* display the image above your post/page content, centered and up to the width of the content, if your image is larger than your Medium Media Setting, and less than or equal to your Large Media Setting.
* display _nothing_ if your featured image width is less than or equal to your Medium Media Setting.
* display _nothing_ if your featured image is already displayed in your content (the original image, not a resized version).
_Note: This plugin works with the Genesis Framework and child themes only._
== Installation ==
1. Upload the entire `display-featured-image-genesis` folder to your `/wp-content/plugins` directory.
1. Activate the plugin through the 'Plugins' menu in WordPress.
1. Optionally, visit the Settings > Media page to change the default behavior of the plugin.
== Frequently Asked Questions ==
= How do I stop the featured image action from showing on my custom post types? =
You'll want to add a filter to your theme (functions.php file). Here's an example:
add_filter( 'display_featured_image_genesis_skipped_posttypes', 'rgc_skip_post_types' );
function rgc_skip_post_types( $post_types ) {
$post_types[] = 'listing';
$post_types[] = 'staff';
return $post_types;
}
= The backstretch image is a little too tall. =
If you do not want the height of the backstretch image to be quite the height of the user's window, you can reduce it by just a hair. Go to Settings > Media and change the 'Reduction amount' number from the default of 0. The higher this number is, the shorter your image will be. Feel free to experiment, as no images are harmed by changing this number.
Additionally/alternatively, you could set a max-height for the backstretch image via css:
.backstretch {
max-height: 700px;
}
== Screenshots ==
1. Screenshot of a page using the Backstretch Featured Image
== Upgrade Notice ==
= 1.1.1 =
corrected XHTML hooks
== Changelog ==
= 1.1.1 =
* corrected XHTML hooks
= 1.1.0 =
* added a setting in the admin to optionally reduce the height of the backstretch image (eg. due to header height issues)
* refactoring
* wp.org release
= 1.0.1 =
* added the filter for certain post types, and optional filter for other custom post types
= 1.0.0 =
* Initial release on Github