Skip to content

Commit

Permalink
Merge pull request #45 from voceconnect/admin_css
Browse files Browse the repository at this point in the history
add admin css to fix thumbnail overflow. fixes #44. props @Oslaf.
  • Loading branch information
chrisscott committed Oct 20, 2014
2 parents ed34a72 + 1666e4a commit e3aeb0f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
4 changes: 4 additions & 0 deletions css/multi-post-thumbnails-admin.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
img.mpt-thumbnail {
width: 100%;
height: auto;
}
18 changes: 12 additions & 6 deletions multi-post-thumbnails.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ public function enqueue_admin_scripts( $hook ) {
wp_enqueue_script( "mpt-featured-image", $this->plugins_url( 'js/multi-post-thumbnails-admin.js', __FILE__ ), array( 'jquery', 'set-post-thumbnail' ) );
wp_enqueue_script( "mpt-featured-image-modal", $this->plugins_url( 'js/media-modal.js', __FILE__ ), array( 'jquery', 'media-models' ) );
}

wp_enqueue_style( "mpt-admin-css", $this->plugins_url( 'css/multi-post-thumbnails-admin.css', __FILE__ ) );
}

public function admin_header_scripts() {
Expand Down Expand Up @@ -394,22 +396,26 @@ private function post_thumbnail_html($thumbnail_id = null) {
if ($thumbnail_id && get_post($thumbnail_id)) {
$old_content_width = $content_width;
$content_width = 266;
if ( !isset($_wp_additional_image_sizes["{$this->post_type}-{$this->id}-thumbnail"]))
$thumbnail_html = wp_get_attachment_image($thumbnail_id, array($content_width, $content_width));
else
$thumbnail_html = wp_get_attachment_image($thumbnail_id, "{$this->post_type}-{$this->id}-thumbnail");
$attr = array( 'class' => 'mpt-thumbnail' );

if ( !isset($_wp_additional_image_sizes["{$this->post_type}-{$this->id}-thumbnail"])) {
$thumbnail_html = wp_get_attachment_image( $thumbnail_id, array($content_width, $content_width), false, $attr );
} else {
$thumbnail_html = wp_get_attachment_image( $thumbnail_id, "{$this->post_type}-{$this->id}-thumbnail", false, $attr );
}

if (!empty($thumbnail_html)) {
$content = sprintf($set_thumbnail_link, $thumbnail_html);
$format_string = '<p class="hide-if-no-js"><a href="#" id="remove-%1$s-%2$s-thumbnail" onclick="MultiPostThumbnails.removeThumbnail(\'%2$s\', \'%1$s\', \'%4$s\');return false;">%3$s</a></p>';
$content .= sprintf( $format_string, $this->post_type, $this->id, sprintf( esc_html__( "Remove %s", 'multiple-post-thumbnails' ), $this->label ), $ajax_nonce );
}
$content_width = $old_content_width;
}

if (version_compare($wp_version, '3.5', '>=')) {
$content .= sprintf('<script>%s</script>', $modal_js);
}

return apply_filters( sprintf( '%s_%s_admin_post_thumbnail_html', $this->post_type, $this->id ), $content, $post_ID, $thumbnail_id );
}

Expand Down

0 comments on commit e3aeb0f

Please sign in to comment.