TinyMCE gallery preview: fix errors when an image doesn't have/is smaller than thumbnail size, props gcorne, see #26959
git-svn-id: https://develop.svn.wordpress.org/trunk@27580 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
30a83e48e2
commit
8e403519db
@ -268,14 +268,25 @@ window.wp = window.wp || {};
|
|||||||
|
|
||||||
getHtml: function() {
|
getHtml: function() {
|
||||||
var attrs = this.shortcode.attrs.named,
|
var attrs = this.shortcode.attrs.named,
|
||||||
options;
|
options,
|
||||||
|
attachments;
|
||||||
|
|
||||||
if ( ! this.attachments.length ) {
|
if ( ! this.attachments.length ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
attachments = this.attachments.toJSON();
|
||||||
|
|
||||||
|
_.each( attachments, function( attachment ) {
|
||||||
|
if ( attachment.sizes.thumbnail ) {
|
||||||
|
attachment.thumbnail = attachment.sizes.thumbnail;
|
||||||
|
} else {
|
||||||
|
attachment.thumbnail = attachment.sizes.full;
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
attachments: this.attachments.toJSON(),
|
attachments: attachments,
|
||||||
columns: attrs.columns ? parseInt( attrs.columns, 10 ) : 3
|
columns: attrs.columns ? parseInt( attrs.columns, 10 ) : 3
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -897,12 +897,6 @@ function wp_print_media_templates() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</script>
|
</script>
|
||||||
<?php
|
|
||||||
|
|
||||||
//TODO: do we want to deal with the fact that the elements used for gallery items are filterable and can be overriden via shortcode attributes
|
|
||||||
// do we want to deal with the difference between display and edit context at all? (e.g. wptexturize() being applied to the caption.
|
|
||||||
?>
|
|
||||||
|
|
||||||
<script type="text/html" id="tmpl-editor-gallery">
|
<script type="text/html" id="tmpl-editor-gallery">
|
||||||
<div class="toolbar">
|
<div class="toolbar">
|
||||||
<div class="dashicons dashicons-edit edit"></div>
|
<div class="dashicons dashicons-edit edit"></div>
|
||||||
@ -912,14 +906,12 @@ function wp_print_media_templates() {
|
|||||||
<# _.each( data.attachments, function( attachment, index ) { #>
|
<# _.each( data.attachments, function( attachment, index ) { #>
|
||||||
<dl class="gallery-item">
|
<dl class="gallery-item">
|
||||||
<dt class="gallery-icon">
|
<dt class="gallery-icon">
|
||||||
<?php // TODO: need to figure out the best way to make sure that we have thumbnails ?>
|
<img src="{{{ attachment.thumbnail.url }}}" width="{{ attachment.thumbnail.width }}" height="{{ attachment.thumbnail.height }}" />
|
||||||
<img src="{{{ attachment.sizes.thumbnail.url }}}" />
|
|
||||||
</dt>
|
</dt>
|
||||||
<dd class="wp-caption-text gallery-caption">
|
<dd class="wp-caption-text gallery-caption">
|
||||||
{{ attachment.caption }}
|
{{ attachment.caption }}
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<?php // this is kind silly, but copied from the gallery shortcode. Maybe it should be removed ?>
|
|
||||||
<# if ( index % data.columns === data.columns - 1 ) { #>
|
<# if ( index % data.columns === data.columns - 1 ) { #>
|
||||||
<br style="clear: both;">
|
<br style="clear: both;">
|
||||||
<# } #>
|
<# } #>
|
||||||
|
Loading…
Reference in New Issue
Block a user