mirror of
https://github.com/10h30/display-featured-image-genesis.git
synced 2026-07-18 05:53:23 +09:00
Change image preview dry
This commit is contained in:
@@ -235,10 +235,7 @@ class Display_Featured_Image_Genesis_Settings {
|
||||
if ( ! is_numeric( $this->displaysetting['default'] ) ) {
|
||||
$id = Display_Featured_Image_Genesis_Common::get_image_id( $this->displaysetting['default'] );
|
||||
}
|
||||
$preview = wp_get_attachment_image_src( absint( $id ), 'medium' );
|
||||
echo '<div id="upload_logo_preview">';
|
||||
printf( '<img src="%s" />', esc_url( $preview[0] ) );
|
||||
echo '</div>';
|
||||
echo wp_kses_post( $this->render_image_preview( $id ) );
|
||||
}
|
||||
echo '<input type="hidden" class="upload_image_id" id="displayfeaturedimagegenesis[default]" name="displayfeaturedimagegenesis[default]" value="' . absint( $id ) . '" />';
|
||||
printf( '<input type="button" class="upload_default_image button-secondary" value="%s" />',
|
||||
@@ -348,10 +345,8 @@ class Display_Featured_Image_Genesis_Settings {
|
||||
if ( ! is_numeric( $this->displaysetting['post_type'][ $post_type ] ) ) {
|
||||
$id = Display_Featured_Image_Genesis_Common::get_image_id( $this->displaysetting['post_type'][ $post_type ] );
|
||||
}
|
||||
$preview = wp_get_attachment_image_src( absint( $id ), 'medium' );
|
||||
echo '<div id="upload_logo_preview">';
|
||||
echo '<img src="' . esc_url( $preview[0] ) . '" />';
|
||||
echo '</div>';
|
||||
|
||||
echo wp_kses_post( $this->render_image_preview( $id ) );
|
||||
}
|
||||
|
||||
echo '<input type="hidden" class="upload_image_id" id="displayfeaturedimagegenesis[post_type][' . esc_attr( $post_type ) . ']" name="displayfeaturedimagegenesis[post_type][' . esc_attr( $post_type ) . ']" value="' . absint( $id ) . '" />';
|
||||
@@ -372,6 +367,21 @@ class Display_Featured_Image_Genesis_Settings {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* display image preview
|
||||
* @param variable $id featured image ID
|
||||
* @return $image image preview
|
||||
*
|
||||
* @since x.y.z
|
||||
*/
|
||||
public function render_image_preview( $id ) {
|
||||
$preview = wp_get_attachment_image_src( absint( $id ), 'medium' );
|
||||
$image = '<div id="upload_logo_preview">';
|
||||
$image .= '<img src="' . esc_url( $preview[0] ) . '" />';
|
||||
$image .= '</div>';
|
||||
return $image;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save extra taxonomy fields callback function.
|
||||
* @param term id $term_id the id of the term
|
||||
|
||||
@@ -57,10 +57,7 @@ class Display_Featured_Image_Genesis_Taxonomies {
|
||||
if ( ! is_numeric( $displaysetting['term_image'] ) ) {
|
||||
$id = Display_Featured_Image_Genesis_Common::get_image_id( $displaysetting['term_image'] );
|
||||
}
|
||||
$preview = wp_get_attachment_image_src( absint( $id ), 'medium' );
|
||||
echo '<div id="upload_logo_preview">';
|
||||
printf( '<img src="%s" width="300" />', esc_url( $preview[0] ) );
|
||||
echo '</div>';
|
||||
echo wp_kses_post( Display_Featured_Image_Genesis_Settings::render_image_preview( $id ) );
|
||||
}
|
||||
echo '<input type="hidden" class="upload_image_id" id="term_image_id" name="displayfeaturedimagegenesis[term_image]" value="' . absint( $id ) . '" />';
|
||||
printf( '<input id="upload_default_image" type="button" class="upload_default_image button-secondary" value="%s" />',
|
||||
|
||||
Reference in New Issue
Block a user