Merge branch 'develop'

This commit is contained in:
Robin Cornett
2014-10-21 19:27:31 -04:00
10 changed files with 280 additions and 166 deletions
+20 -1
View File
@@ -10,8 +10,9 @@ This plugin takes a different approach to how we use and display featured images
* 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).
* display a _default featured image_ as a backstretch image if one is uploaded.
__New in 1.2.0:__ you can now use the WordPress Customizer to set a _Default Featured Image_ to be used site-wide. This image will be used on any post/page/custom post type which does not have a featured image set.
__New in 1.2.0:__ on the Media Settings page, you can now upload a _Default Featured Image_ to be used site-wide. This image will be used on any post/page/custom post type which does not have a featured image set, plus archive and taxonomy pages.
_Note: This plugin works with the Genesis Framework and child themes only._
@@ -70,6 +71,19 @@ function rgc_skip_post_types( $post_types ) {
It seems that you can also include [conditional tags](http://codex.wordpress.org/Conditional_Tags) in the above, eg `$post_types[] = is_front_page();` to stop the featured image from displaying. This is most helpful if you have set a default featured image in the Customizer.
### Can I force my site to use the default image on a post type even if it has its own Featured Image?
Yes! You'll want to add a filter to your theme (functions.php file). Here's an example:
```php
add_filter( 'display_featured_image_genesis_use_default', 'rgc_force_default_image' );
function rgc_force_default_image( $post_types ) {
$post_types[] = 'attorney';
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 'Height' 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.
@@ -87,6 +101,11 @@ Additionally/alternatively, you could set a max-height for the backstretch image
## Changelog
###1.2.1
* moved default image from Customizer to Media Settings page
* new filter for forcing default image for any post type
* common class
###1.2.0
* new feature: default featured image to display if no image is set
* better method naming/organization
+4 -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.2.0
* Version: 1.2.1
* Author: Robin Cornett
* Author URI: http://robincornett.com
* License: GPL-2.0+
@@ -26,14 +26,17 @@ if ( ! defined( 'WPINC' ) ) {
// Include classes
require plugin_dir_path( __FILE__ ) . 'includes/class-displayfeaturedimagegenesis.php';
require plugin_dir_path( __FILE__ ) . 'includes/class-displayfeaturedimagegenesis-common.php';
require plugin_dir_path( __FILE__ ) . 'includes/class-displayfeaturedimagegenesis-output.php';
require plugin_dir_path( __FILE__ ) . 'includes/class-displayfeaturedimagegenesis-settings.php';
// Instantiate dependent classes
$displayfeaturedimagegenesis_common = new Display_Featured_Image_Genesis_Common();
$displayfeaturedimagegenesis_output = new Display_Featured_Image_Genesis_Output();
$displayfeaturedimagegenesis_settings = new Display_Featured_Image_Genesis_Settings();
$displayfeaturedimage = new Display_Featured_Image_Genesis(
$displayfeaturedimagegenesis_common,
$displayfeaturedimagegenesis_output,
$displayfeaturedimagegenesis_settings
);
@@ -0,0 +1,42 @@
<?php
/**
* Common functions for plugin
*
* @package DisplayFeaturedImageGenesis
* @since 1.2.1
*/
class Display_Featured_Image_Genesis_Common {
/**
* Get the ID of each image dynamically.
*
* @since 1.2.0
*
* @author Philip Newcomer
* @link http://philipnewcomer.net/2012/11/get-the-attachment-id-from-an-image-url-in-wordpress/
*/
static function get_image_id( $attachment_url ) {
global $wpdb;
$attachment_id = false;
// Get the upload directory paths
$upload_dir_paths = wp_upload_dir();
// Make sure the upload path base directory exists in the attachment URL, to verify that we're working with a media library image
if ( false !== strpos( $attachment_url, $upload_dir_paths['baseurl'] ) ) {
// If this is the URL of an auto-generated thumbnail, get the URL of the original image
$attachment_url = preg_replace( '(-\d{3,4}x\d{3,4}.)', '.', $attachment_url );
// Remove the upload path base directory from the attachment URL
$attachment_url = str_replace( $upload_dir_paths['baseurl'] . '/', '', $attachment_url );
// Finally, run a custom database query to get the attachment ID from the modified attachment URL
$attachment_id = $wpdb->get_var( $wpdb->prepare( "SELECT wposts.ID FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = '_wp_attached_file' AND wpostmeta.meta_value = '%s' AND wposts.post_type = 'attachment'", $attachment_url ) );
}
return $attachment_id;
}
}
@@ -1,57 +0,0 @@
<?php
/**
* Customize Background Image Control Class
*
* @package WordPress
* @subpackage Customize
* @since 1.2.0
*/
class Display_Featured_Image_Genesis_Customizer extends WP_Customize_Image_Control {
/**
* Constructor.
*
* If $args['settings'] is not defined, use the $id as the setting ID.
*
* @since 1.2.0
* @uses WP_Customize_Upload_Control::__construct()
*
* @param WP_Customize_Manager $manager
* @param string $id
* @param array $args
*/
public function __construct( $manager, $id, $args ) {
$this->statuses = array( '' => __( 'No Image', 'display-featured-image-genesis' ) );
parent::__construct( $manager, $id, $args );
$this->add_tab( 'upload-new', __( 'Upload New', 'display-featured-image-genesis' ), array( $this, 'tab_upload_new' ) );
$this->add_tab( 'uploaded', __( 'Uploaded', 'display-featured-image-genesis' ), array( $this, 'tab_uploaded' ) );
if ( $this->setting->default )
$this->add_tab( 'default', __( 'Default', 'display-featured-image-genesis' ), array( $this, 'tab_default_background' ) );
// Early priority to occur before $this->manager->prepare_controls();
add_action( 'customize_controls_init', array( $this, 'prepare_control' ), 5 );
}
}
global $wp_customize;
$wp_customize->add_section( 'displayfeaturedimage-settings', array(
'title' => __( 'Default Featured Image', 'display-featured-image-genesis' ),
'priority' => 105,
) );
$wp_customize->add_setting( 'displayfeaturedimage_default', array(
'type' => 'option',
) );
$wp_customize->add_control( new Display_Featured_Image_Genesis_Customizer( $wp_customize, 'displayfeaturedimage_default', array(
'label' => __( 'Display Featured Image for Genesis', 'display-featured-image-genesis' ),
'description' => __( 'You may set a default image to be used as the backstretch or large featured image if no image is selected for the post/page.', 'display-featured-image-genesis' ),
'section' => 'displayfeaturedimage-settings',
'settings' => 'displayfeaturedimage_default',
) ) );
@@ -15,10 +15,11 @@ class Display_Featured_Image_Genesis_Output {
* @since 1.1.3
*/
public function manage_output() {
if ( in_array( get_post_type(), $this->get_skipped_posttypes() ) ) {
$fallback = get_option( 'displayfeaturedimage_default' );
if ( ( empty( $fallback ) && !is_home() && !is_singular() ) || ( in_array( get_post_type(), $this->get_skipped_posttypes() ) ) ) {
return;
}
elseif ( is_home() || is_singular() ) {
else {
add_action( 'wp_enqueue_scripts', array( $this, 'load_scripts' ) );
add_filter( 'body_class', array( $this, 'add_body_class' ) );
}
@@ -34,32 +35,49 @@ class Display_Featured_Image_Genesis_Output {
$item = new stdClass();
global $post;
$fallback = get_option( 'displayfeaturedimage_default' );
$fallback_id = Display_Featured_Image_Genesis_Common::get_image_id( $fallback );
$frontpage = get_option( 'show_on_front' ); // either 'posts' or 'page'
$postspage = get_option( 'page_for_posts' );
$postspage_image = get_post_thumbnail_id( $postspage );
if ( is_singular() ) {
$originalthumb = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'displayfeaturedimage_backstretch' );
}
$item->large = get_option( 'large_size_w' );
$item->medium = get_option( 'medium_size_w' );
$item->reduce = get_option( 'displayfeaturedimage_less_header', 0 );
// Set Featured Image Source
if ( is_home() && !empty( $postspage_image ) ) {
$item->original = wp_get_attachment_image_src( get_post_thumbnail_id( $postspage ), 'original' );
if ( is_home() && $frontpage === 'page' && !empty( $postspage_image ) ) { // if on the blog page and it has a post_thumbnail
$item->original = wp_get_attachment_image_src( $postspage_image, 'displayfeaturedimage_backstretch' );
}
elseif ( !empty( $fallback ) && !has_post_thumbnail() ) {
$fallback_id = $this->get_image_id( $fallback );
$item->original = wp_get_attachment_image_src( $fallback_id, 'original' );
// any singular post/page/CPT with either a post_thumbnail larger than medium size OR there is no $fallback
elseif ( is_singular() && ( $originalthumb[1] > $item->medium || empty( $fallback ) ) && !in_array( get_post_type(), $this->use_fallback_image() ) ) {
$item->original = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'displayfeaturedimage_backstretch' );
}
// otherwise use $fallback. should include !is_singular AND $fallback, and is_singular with either a small image or no post_thumbnail
else {
$item->original = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'original' );
$item->original = wp_get_attachment_image_src( $fallback_id, 'displayfeaturedimage_backstretch' );
}
// Set Post/Page Title
if ( is_home() ) {
if ( is_singular() && ! is_front_page() ) {
$item->title = get_the_title();
}
elseif ( is_home() && $frontpage === 'page' ) {
$item->title = get_post( $postspage )->post_title;
}
else {
$item->title = get_the_title();
$item->title = '';
}
// declare this last so that $item->original is set.
if ( !empty( $post->post_content ) ) {
$item->content = strpos( $post->post_content, $item->original[0] );
}
else {
$item->content = '';
}
$item->large = get_option( 'large_size_w' );
$item->medium = get_option( 'medium_size_w' );
$item->reduce = get_option( 'displayfeaturedimage_less_header', 0 );
$item->content = strpos( $post->post_content, $item->original[0] );
return $item;
@@ -75,6 +93,16 @@ class Display_Featured_Image_Genesis_Output {
return apply_filters( 'display_featured_image_genesis_skipped_posttypes', array( 'attachment', 'revision', 'nav_menu_item' ) );
}
/**
* use fallback image as backstretch
* @return filter creates a new filter for themes/plugins to use to use the fallback image even if a large featured image is in place
*
* @since 1.2.1
*/
public function use_fallback_image() {
return apply_filters( 'display_featured_image_genesis_use_default', array( 'attachment', 'revision', 'nav_menu_item' ) );
}
/**
* enqueue plugin styles and scripts.
* @return enqueue
@@ -84,18 +112,18 @@ class Display_Featured_Image_Genesis_Output {
public function load_scripts() {
$item = $this->get_image_variables();
if ( ( !empty( $item->original ) && $item->content === false ) || is_home() ) {
if ( ( !empty( $item->original ) && $item->content === false ) || ( !is_singular() && !empty( $item->original ) ) ) {
wp_enqueue_style( 'displayfeaturedimage-style', plugins_url( 'includes/css/display-featured-image-genesis.css', dirname( __FILE__ ) ), array(), 1.0 );
if ( ( ( $item->original[1] ) > $item->large ) ) {
if ( $item->original[1] > $item->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' );
wp_localize_script( 'displayfeaturedimage-backstretch-set', 'BackStretchVars', array(
'src' => $item->original[0],
'src' => esc_url( $item->original[0] ),
'height' => esc_attr( $item->reduce )
));
) );
add_action( 'genesis_after_header', array( $this, 'do_backstretch_image_title' ) );
@@ -119,7 +147,7 @@ class Display_Featured_Image_Genesis_Output {
$item = $this->get_image_variables();
if ( !empty( $item->original ) && $item->content === false ) {
if ( ( !empty( $item->original ) && $item->content === false ) || ( !is_singular() && !empty( $item->original ) ) ) {
if ( $item->original[1] > $item->large ) {
$classes[] = 'has-leader';
}
@@ -140,7 +168,7 @@ class Display_Featured_Image_Genesis_Output {
$item = $this->get_image_variables();
if ( ! is_home() ) {
if ( is_singular() && !is_front_page() ) {
remove_action( 'genesis_entry_header', 'genesis_do_post_title' ); // HTML5
remove_action( 'genesis_post_title', 'genesis_do_post_title' ); // XHTML
}
@@ -161,36 +189,4 @@ class Display_Featured_Image_Genesis_Output {
echo get_the_post_thumbnail( $post->ID, 'large', array( 'class' => 'aligncenter featured', 'alt' => the_title_attribute( 'echo=0' ) ) );
}
/**
* Get the ID of each image dynamically.
*
* @since 1.2.0
*
* @author Philip Newcomer
* @link http://philipnewcomer.net/2012/11/get-the-attachment-id-from-an-image-url-in-wordpress/
*/
protected function get_image_id( $attachment_url ) {
global $wpdb;
$attachment_id = false;
// Get the upload directory paths
$upload_dir_paths = wp_upload_dir();
// Make sure the upload path base directory exists in the attachment URL, to verify that we're working with a media library image
if ( false !== strpos( $attachment_url, $upload_dir_paths['baseurl'] ) ) {
// If this is the URL of an auto-generated thumbnail, get the URL of the original image
$attachment_url = preg_replace( '(-\d{3,4}x\d{3,4}.)', '.', $attachment_url );
// Remove the upload path base directory from the attachment URL
$attachment_url = str_replace( $upload_dir_paths['baseurl'] . '/', '', $attachment_url );
// Finally, run a custom database query to get the attachment ID from the modified attachment URL
$attachment_id = $wpdb->get_var( $wpdb->prepare( "SELECT wposts.ID FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = '_wp_attached_file' AND wpostmeta.meta_value = '%s' AND wposts.post_type = 'attachment'", $attachment_url ) );
}
return $attachment_id;
}
}
@@ -17,6 +17,8 @@ class Display_Featured_Image_Genesis_Settings {
*/
public function register_settings() {
register_setting( 'media', 'displayfeaturedimage_less_header', 'absint' );
register_setting( 'media', 'displayfeaturedimage_default' );
add_settings_section(
'display_featured_image_section',
@@ -33,6 +35,16 @@ class Display_Featured_Image_Genesis_Settings {
'display_featured_image_section'
);
add_settings_field(
'displayfeaturedimage_default',
'<label for="displayfeaturedimage_default">' . __( 'Default Featured Image', 'display-featured-image-genesis' ) . '</label>',
array( $this, 'set_default_image' ),
'media',
'display_featured_image_section'
);
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
}
/**
@@ -42,7 +54,7 @@ class Display_Featured_Image_Genesis_Settings {
* @since 1.1.0
*/
public function section_description() {
echo '<p>' . __( 'Change this setting to reduce the maximum height of the backstretch image.', 'display-featured-image-genesis' ) . '</p>';
echo '<p>' . __( 'The Display Featured Image for Genesis plugin has two optional settings: 1) change the height of the backstretch effect, and 2) set a default backstretch image to use if no featured image is set.', 'display-featured-image-genesis' ) . '</p>';
}
/**
@@ -60,6 +72,33 @@ class Display_Featured_Image_Genesis_Settings {
}
/**
* Default image uploader
*
* @return image
*
* @since 1.2.1
*/
public function set_default_image() {
$value = get_option( 'displayfeaturedimage_default' );
$id = Display_Featured_Image_Genesis_Common::get_image_id( $value );
$url = wp_get_attachment_image_src( $id, 'medium' );
$original = wp_get_attachment_image_src( $id, 'original' );
$large = get_option( 'large_size_w' );
if ( $value && $original[1] >= $large ) {
echo '<div id="upload_logo_preview">';
echo '<img src="' . $url[0] . '" style="max-width:400px" />';
echo '</div>';
}
elseif ( $value && $original[1] <= $large ) {
echo '<div class="error"><p>' . __( 'Sorry, your image is too small to serve as the default featured image.', 'display-featured-image-genesis' ) . '</p></div>';
}
echo '<input type="text" id="default_image_url" name="displayfeaturedimage_default" value="' . $value . '" />';
echo '<input id="upload_default_image" type="button" class="upload_default_image button" value="' . __( 'Select Default Image', 'display-featured-image-genesis' ) . '" />';
echo '<p class="description">' . __( 'If you would like to use a default image for the featured image, upload it here. Must be a backstretch sized image.', 'display-featured-image-genesis' ) . '</p>';
}
/**
* Help tab for media screen
* @return help tab with verbose information for plugin
@@ -81,4 +120,20 @@ class Display_Featured_Image_Genesis_Settings {
}
/**
* enqueue admin scripts
* @return scripts to use image uploader
*
* @since 1.2.1
*/
public function enqueue_scripts() {
wp_register_script( 'displayfeaturedimage-upload', plugins_url( '/includes/js/settings-upload.js', dirname( __FILE__ ) ), array( 'jquery', 'media-upload', 'thickbox' ), '1.0.0' );
if ( 'options-media' == get_current_screen()->id ) {
wp_enqueue_media();
wp_enqueue_script( 'displayfeaturedimage-upload' );
}
}
}
+8 -11
View File
@@ -15,7 +15,11 @@
* @package DisplayFeaturedImageGenesis
*/
class Display_Featured_Image_Genesis {
function __construct( $output, $settings ) {
public static $instance;
function __construct( $common, $output, $settings ) {
$this->common = $common;
$this->output = $output;
$this->settings = $settings;
}
@@ -26,9 +30,11 @@ class Display_Featured_Image_Genesis {
add_action( 'admin_notices', array( $this, 'error_message' ) );
return;
}
add_image_size( 'displayfeaturedimage_backstretch', 2000 );
add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
add_action( 'admin_init', array( $this->settings, 'register_settings' ) );
add_action( 'customize_register', array( $this, 'load_customizer' ) );
add_action( 'load-options-media.php', array( $this->settings, 'help' ) );
add_action( 'get_header', array( $this->output, 'manage_output' ) );
}
@@ -79,13 +85,4 @@ class Display_Featured_Image_Genesis {
load_plugin_textdomain( 'display-featured-image-genesis', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
}
/**
* Set up Customizer options for default featured image
*
* @since 1.2.0
*/
function load_customizer() {
require plugin_dir_path( __FILE__ ) . 'class-displayfeaturedimagegenesis-customizer.php';
}
}
+35
View File
@@ -0,0 +1,35 @@
jQuery(document).ready(function($){
var custom_uploader;
$('#upload_default_image').click(function(e) {
e.preventDefault();
//If the uploader object has already been created, reopen the dialog
if (custom_uploader) {
custom_uploader.open();
return;
}
//Extend the wp.media object
custom_uploader = wp.media.frames.file_frame = wp.media({
title: 'Choose Image',
button: {
text: 'Choose Image'
},
multiple: false
});
//When a file is selected, grab the URL and set it as the text field's value
custom_uploader.on('select', function() {
attachment = custom_uploader.state().get('selection').first().toJSON();
$('#default_image_url').val(attachment.url);
});
//Open the uploader dialog
custom_uploader.open();
});
});
+46 -40
View File
@@ -4,9 +4,10 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Display Featured Image for Genesis 1.2.0\n"
"Project-Id-Version: Display Featured Image for Genesis 1.2.1\n"
"POT-Creation-Date: 2014-09-17 21:11-0500\n"
"PO-Revision-Date: 2014-10-15 15:45-0500\n""Last-Translator: Robin Cornett <hello@robincornett.com>\n"
"PO-Revision-Date: 2014-10-21 18:03-0500\n"
"Last-Translator: Robin Cornett <hello@robincornett.com>\n"
"Language-Team: Robin Cornett <hello@robincornett.com>\n"
"Language: en_US\n"
"MIME-Version: 1.0\n"
@@ -24,62 +25,55 @@ msgstr ""
"X-Poedit-SearchPath-0: .\n"
"X-Textdomain-Support: yes\n"
#: ../includes/class-displayfeaturedimagegenesis-customizer.php:25
msgid "No Image"
msgstr ""
#: ../includes/class-displayfeaturedimagegenesis-customizer.php:29
msgid "Upload New"
msgstr ""
#: ../includes/class-displayfeaturedimagegenesis-customizer.php:30
msgid "Uploaded"
msgstr ""
#: ../includes/class-displayfeaturedimagegenesis-customizer.php:33
msgid "Default"
msgstr ""
#: ../includes/class-displayfeaturedimagegenesis-customizer.php:52
msgid "Default Featured Image"
msgstr ""
#: ../includes/class-displayfeaturedimagegenesis-customizer.php:62
#: ../includes/class-displayfeaturedimagegenesis-settings.php:23
#: ../includes/class-displayfeaturedimagegenesis-settings.php:78
#: ../includes/class-displayfeaturedimagegenesis-settings.php:25
#: ../includes/class-displayfeaturedimagegenesis-settings.php:120
msgid "Display Featured Image for Genesis"
msgstr ""
#: ../includes/class-displayfeaturedimagegenesis-customizer.php:63
msgid ""
"You may set a default image to be used as the backstretch or large featured "
"image if no image is selected for the post/page."
msgstr ""
#: ../includes/class-displayfeaturedimagegenesis-settings.php:30
#: ../includes/class-displayfeaturedimagegenesis-settings.php:32
msgid "Height"
msgstr ""
#: ../includes/class-displayfeaturedimagegenesis-settings.php:45
msgid ""
"Change this setting to reduce the maximum height of the backstretch image."
#: ../includes/class-displayfeaturedimagegenesis-settings.php:40
msgid "Default Featured Image"
msgstr ""
#: ../includes/class-displayfeaturedimagegenesis-settings.php:57
msgid ""
"The Display Featured Image for Genesis plugin has two optional settings: 1) "
"change the height of the backstretch effect, and 2) set a default "
"backstretch image to use if no featured image is set."
msgstr ""
#: ../includes/class-displayfeaturedimagegenesis-settings.php:69
msgid "Pixels to remove "
msgstr ""
#: ../includes/class-displayfeaturedimagegenesis-settings.php:59
#: ../includes/class-displayfeaturedimagegenesis-settings.php:71
msgid ""
"Changing this number will reduce the backstretch image height by this number "
"of pixels. Default is zero."
msgstr ""
#: ../includes/class-displayfeaturedimagegenesis-settings.php:73
#: ../includes/class-displayfeaturedimagegenesis-settings.php:95
msgid "Sorry, your image is too small to serve as the default featured image."
msgstr ""
#: ../includes/class-displayfeaturedimagegenesis-settings.php:98
msgid "Select Default Image"
msgstr ""
#: ../includes/class-displayfeaturedimagegenesis-settings.php:99
msgid ""
"If you would like to use a default image for the featured image, upload it "
"here. Must be a backstretch sized image."
msgstr ""
#: ../includes/class-displayfeaturedimagegenesis-settings.php:112
msgid "Reducto!"
msgstr ""
#: ../includes/class-displayfeaturedimagegenesis-settings.php:74
#: ../includes/class-displayfeaturedimagegenesis-settings.php:113
msgid ""
"Depending on how your header/nav are set up, or if you just do not want your "
"backstretch image to extend to the bottom of the user screen, you may want "
@@ -87,13 +81,25 @@ msgid ""
"image, making it shorter."
msgstr ""
#: ../includes/class-displayfeaturedimagegenesis.php:63
#: ../includes/class-displayfeaturedimagegenesis-settings.php:115
msgid "Set a Default Featured Image"
msgstr ""
#: ../includes/class-displayfeaturedimagegenesis-settings.php:116
msgid ""
"You may set a large image to be used sitewide if a featured image is not "
"available. This image will show on posts, pages, and archives. It must be "
"larger than your site&#39;s Large Image setting, or else it will not "
"display. This is for a backstretch image only."
msgstr ""
#: ../includes/class-displayfeaturedimagegenesis.php:65
msgid ""
"Sorry, Display Featured Image for Genesis works only with the Genesis "
"Framework. It has been deactivated."
msgstr ""
#: ../includes/class-displayfeaturedimagegenesis.php:67
#: ../includes/class-displayfeaturedimagegenesis.php:69
#, php-format
msgid ""
"Sorry, Display Featured Image for Genesis works only with the Genesis "
+21 -3
View File
@@ -18,9 +18,9 @@ This plugin takes a different approach to how we use and display featured images
* 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).
* display a _default featured image_ as a backstretch image if one is uploaded.
__New in 1.2.0:__ you can now use the WordPress Customizer to set a _Default Featured Image_ to be used site-wide. This image will be used on any post/page/custom post type which does not have a featured image set.
__New in 1.2.0:__ on the Media Settings page, you can now upload a _Default Featured Image_ to be used site-wide. This image will be used on any post/page/custom post type which does not have a featured image set, plus archive and taxonomy pages.
_Note: This plugin works with the Genesis Framework and child themes only._
@@ -46,6 +46,19 @@ You'll want to add a filter to your theme (functions.php file). Here's an exampl
It seems that you can also include [conditional tags](http://codex.wordpress.org/Conditional_Tags) in the above, eg `$post_types[] = is_front_page();` to stop the featured image from displaying. This is most helpful if you have set a default featured image in the Customizer.
= Can I force my site to use the default image on a post type even if it has its own Featured Image? =
Yes! You'll want to add a filter to your theme (functions.php file). Here's an example:
```php
add_filter( 'display_featured_image_genesis_use_default', 'rgc_force_default_image' );
function rgc_force_default_image( $post_types ) {
$post_types[] = 'attorney';
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 'Height' 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.
@@ -63,11 +76,16 @@ Additionally/alternatively, you could set a max-height for the backstretch image
2. Use the WordPress Customizer to set a Default Featured Image.
== Upgrade Notice ==
= 1.2.0 =
= 1.2.1 =
New feature: Set a Default Featured Image
== Changelog ==
= 1.2.1 =
* moved default image from Customizer to Media Settings page
* new filter for forcing default image for any post type
* common class
= 1.2.0 =
* new feature: default featured image to display if no image is set
* better method naming/organization