diff --git a/README.md b/README.md index 6ee2b31..37318fa 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ This plugin takes a different approach to how we use and display featured images ## Requirements * WordPress 3.8, tested up to 4.0 -* the Genesis Framework with an HTML5 child theme. +* the Genesis Framework ## Installation @@ -42,10 +42,19 @@ Then go to your Plugins screen and click __Activate__. ## Frequently Asked Questions +### How do I stop the featured image action from showing on my custom post types? -### What is Simplify Feed? +You'll want to add a filter to your theme (functions.php file). Here's an example: -If you use native WordPress galleries in your posts, they're sent to your feed as thumbnails. Even if you do not use an RSS/email service, you can still use this plugin to sort out your galleries for subscribers who use an RSS reader. If you select Simplify Feed, your galleries will be converted, but there will not be an email sized image created, and no alternate feed will be created. +```php +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; +} +``` ## Credits @@ -53,5 +62,8 @@ If you use native WordPress galleries in your posts, they're sent to your feed a ## Changelog +###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 \ No newline at end of file diff --git a/display-featured-image-genesis.php b/display-featured-image-genesis.php index ac4da64..8060812 100644 --- a/display-featured-image-genesis.php +++ b/display-featured-image-genesis.php @@ -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.0.0 + * Version: 1.0.1 * Author: Robin Cornett * Author URI: http://robincornett.com * License: GPL-2.0+ diff --git a/includes/class-displayfeaturedimagegenesis.php b/includes/class-displayfeaturedimagegenesis.php index 5e638a0..4ade9ed 100644 --- a/includes/class-displayfeaturedimagegenesis.php +++ b/includes/class-displayfeaturedimagegenesis.php @@ -1,6 +1,6 @@ @@ -18,7 +18,6 @@ class Display_Featured_Image_Genesis { function __construct() { add_action( 'wp_enqueue_scripts', array( $this, 'load_scripts' ) ); add_filter( 'body_class', array( $this, 'add_body_class' ) ); - add_action( 'genesis_before', array( $this, 'do_featured_image' ) ); } /** @@ -45,6 +44,17 @@ class Display_Featured_Image_Genesis { } + + /** + * skip certain post types + * @return filter creates a new filter for themes/plugins to use to skip certain post types + * + * @since 1.0.1 + */ + public function get_skipped_posttypes() { + return apply_filters( 'display_featured_image_genesis_skipped_posttypes', array( 'attachment', 'revision', 'nav_menu_item' ) ); + } + /** * enqueue plugin styles and scripts. * @return enqueue @@ -52,13 +62,19 @@ class Display_Featured_Image_Genesis { * @since 1.0.0 */ public function load_scripts() { - $image = $this->get_image_variables(); - if ( has_post_thumbnail() && $image->content === false ) { + if ( !is_home() && in_array( get_post_type(), $this->get_skipped_posttypes() ) ) { + return; + } + + $image = $this->get_image_variables(); + if ( ( has_post_thumbnail() && $image->content === false ) || is_home() ) { wp_enqueue_style( 'displayfeaturedimage-style', plugins_url( 'includes/css/display-featured-image-genesis.css', dirname( __FILE__ ) ), array(), 1.0 ); - if ( ( $image->original[1] ) >= $image->large ) { + add_action( 'genesis_before', array( $this, 'do_featured_image' ) ); + + if ( ( $image->original[1] ) > $image->large ) { wp_enqueue_script( 'displayfeaturedimage-backstretch', plugins_url( '/includes/js/backstretch.js', dirname( __FILE__ ) ), array( 'jquery' ), '1.0.0' ); wp_enqueue_script( 'displayfeaturedimage-backstretch-set', plugins_url( '/includes/js/backstretch-set.js', dirname( __FILE__ ) ), array( 'jquery', 'displayfeaturedimage-backstretch' ), '1.0.0' ); @@ -80,7 +96,7 @@ class Display_Featured_Image_Genesis { $image = $this->get_image_variables(); if ( $image->content === false ) { - if ( has_post_thumbnail( $post->ID ) && $image->original[1] > $image->large ) { + if ( ( has_post_thumbnail() || is_home() ) && $image->original[1] > $image->large ) { $classes[] = 'has-leader'; } elseif ( has_post_thumbnail( $post->ID ) && ( ( $image->original[1] <= $image->large ) && ( $image->original[1] > $image->medium ) ) ) { @@ -119,7 +135,6 @@ class Display_Featured_Image_Genesis { * @since 1.0.0 */ public function do_backstretch_image() { - global $post; $image = $this->get_image_variables(); diff --git a/includes/js/backstretch-set.js b/includes/js/backstretch-set.js index fcf4215..161e43b 100644 --- a/includes/js/backstretch-set.js +++ b/includes/js/backstretch-set.js @@ -1,4 +1,4 @@ jQuery(document).ready(function($) { $(".big-leader").css({'height':($(window).height())+'px'}); - $(".big-leader").backstretch([BackStretchImg.src],{'positionType':'fixed','duration':5000,'fade':750}); + $(".big-leader").backstretch([BackStretchImg.src],{'positionType':'fixed','fade':750,'centeredY':false}); }); \ No newline at end of file