mirror of
https://github.com/10h30/display-featured-image-genesis.git
synced 2026-07-18 22:13:20 +09:00
Add max-height setting/CSS via inline style
This commit is contained in:
@@ -60,6 +60,9 @@ class Display_Featured_Image_Genesis_Output {
|
||||
}
|
||||
$css_file = apply_filters( 'display_featured_image_genesis_css_file', plugin_dir_url( __FILE__ ) . 'css/display-featured-image-genesis.css' );
|
||||
wp_enqueue_style( 'displayfeaturedimage-style', esc_url( $css_file ), array(), $this->common->version );
|
||||
if ( $this->setting['max_height'] ) {
|
||||
$this->add_inline_style();
|
||||
}
|
||||
add_filter( 'body_class', array( $this, 'add_body_class' ) );
|
||||
|
||||
$large = $this->common->minimum_backstretch_width();
|
||||
@@ -76,6 +79,16 @@ class Display_Featured_Image_Genesis_Output {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add max_height to output via inline style.
|
||||
*
|
||||
* @since 2.6.0
|
||||
*/
|
||||
public function add_inline_style() {
|
||||
$css = sprintf( '.big-leader { max-height: %spx }', $this->setting['max_height'] );
|
||||
wp_add_inline_style( 'displayfeaturedimage-style', strip_tags( $css ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* set body class if featured images are displayed using the plugin
|
||||
* @param filter $classes body_class
|
||||
|
||||
@@ -150,6 +150,7 @@ class Display_Featured_Image_Genesis_Settings extends Display_Featured_Image_Gen
|
||||
'post_types' => array(),
|
||||
'skip' => array(),
|
||||
'fallback' => array(),
|
||||
'max_height' => '',
|
||||
) );
|
||||
}
|
||||
|
||||
@@ -204,6 +205,13 @@ class Display_Featured_Image_Genesis_Settings extends Display_Featured_Image_Gen
|
||||
'section' => 'main',
|
||||
'args' => array( 'setting' => 'less_header', 'label' => __( 'pixels to remove', 'display-featured-image-genesis' ), 'min' => 0, 'max' => 400 ),
|
||||
),
|
||||
array(
|
||||
'id' => 'max_height',
|
||||
'title' => __( 'Maximum Height' , 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_number',
|
||||
'section' => 'main',
|
||||
'args' => array( 'setting' => 'max_height', 'label' => __( 'pixels', 'display-featured-image-genesis' ), 'min' => 100, 'max' => 1000 ),
|
||||
),
|
||||
array(
|
||||
'id' => 'default',
|
||||
'title' => __( 'Default Featured Image', 'display-featured-image-genesis' ),
|
||||
@@ -331,6 +339,15 @@ class Display_Featured_Image_Genesis_Settings extends Display_Featured_Image_Gen
|
||||
return __( 'Changing this number will reduce the backstretch image height by this number of pixels. Default is zero.', 'display-featured-image-genesis' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Description for the max_height setting.
|
||||
* @return string|void description
|
||||
* @since 2.6.0
|
||||
*/
|
||||
protected function max_height_description() {
|
||||
return __( 'Optionally, set a max-height value for the header image; it will be added to your CSS.', 'display-featured-image-genesis' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Default image uploader
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user