Twenty Sixteen: Update theme’s wide image styles to include Image Blocks
Twenty Sixteen includes functionality and styles that make full-size images extend wider than the content when they are added to posts, and appear below the post meta. This update adds the same behavior to image blocks and their captions. Merges [43911] to trunk. Props laurelfulford. Fixes: #45380. git-svn-id: https://develop.svn.wordpress.org/trunk@44263 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
7a20625cf0
commit
1b14dfa064
@ -25,6 +25,11 @@ Description: Used to style Gutenberg Blocks.
|
|||||||
font-style: italic;
|
font-style: italic;
|
||||||
line-height: 1.6153846154;
|
line-height: 1.6153846154;
|
||||||
padding-top: 0.5384615385em;
|
padding-top: 0.5384615385em;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rtl [class^="wp-block-"] figcaption {
|
||||||
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------
|
/*--------------------------------------------------------------
|
||||||
@ -37,6 +42,24 @@ p.has-drop-cap:not(:focus)::first-letter {
|
|||||||
font-size: 5em;
|
font-size: 5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Image */
|
||||||
|
|
||||||
|
@media screen and (min-width: 61.5625em) {
|
||||||
|
body:not(.search-results) article:not(.type-page) .wp-block-image figcaption.below-entry-meta {
|
||||||
|
clear: both;
|
||||||
|
display: block;
|
||||||
|
float: none;
|
||||||
|
margin-right: 0;
|
||||||
|
margin-left: -40%;
|
||||||
|
max-width: 140%;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.rtl:not(.search-results) article:not(.type-page) .wp-block-image figcaption.below-entry-meta {
|
||||||
|
margin-left: 0;
|
||||||
|
margin-right: -40%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Gallery */
|
/* Gallery */
|
||||||
|
|
||||||
.wp-block-gallery {
|
.wp-block-gallery {
|
||||||
|
@ -262,6 +262,11 @@ Description: Used to style Gutenberg Blocks in the editor.
|
|||||||
font-style: italic;
|
font-style: italic;
|
||||||
line-height: 1.6153846154;
|
line-height: 1.6153846154;
|
||||||
padding-top: 0.5384615385em;
|
padding-top: 0.5384615385em;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rtl [class^="wp-block-"] figcaption {
|
||||||
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------
|
/*--------------------------------------------------------------
|
||||||
|
@ -148,26 +148,37 @@
|
|||||||
entryFooterPos = entryFooter.offset(),
|
entryFooterPos = entryFooter.offset(),
|
||||||
entryFooterPosBottom = entryFooterPos.top + ( entryFooter.height() + 28 ),
|
entryFooterPosBottom = entryFooterPos.top + ( entryFooter.height() + 28 ),
|
||||||
caption = element.closest( 'figure' ),
|
caption = element.closest( 'figure' ),
|
||||||
|
figcaption = element.next( 'figcaption' ),
|
||||||
newImg;
|
newImg;
|
||||||
|
|
||||||
// Add 'below-entry-meta' to elements below the entry meta.
|
// Add 'below-entry-meta' to elements below the entry meta.
|
||||||
if ( elementPosTop > entryFooterPosBottom ) {
|
if ( elementPosTop > entryFooterPosBottom ) {
|
||||||
|
|
||||||
// Check if full-size images and captions are larger than or equal to 840px.
|
// Check if full-size images and captions are larger than or equal to 840px.
|
||||||
if ( 'img.size-full' === param ) {
|
if ( 'img.size-full' === param || '.wp-block-image img' === param ) {
|
||||||
|
|
||||||
// Create an image to find native image width of resized images (i.e. max-width: 100%).
|
// Create an image to find native image width of resized images (i.e. max-width: 100%).
|
||||||
newImg = new Image();
|
newImg = new Image();
|
||||||
newImg.src = element.attr( 'src' );
|
newImg.src = element.attr( 'src' );
|
||||||
|
|
||||||
$( newImg ).on( 'load.twentysixteen', function() {
|
$( newImg ).on( 'load.twentysixteen', function() {
|
||||||
if ( newImg.width >= 840 ) {
|
if ( newImg.width >= 840 ) {
|
||||||
|
|
||||||
|
// Check if an image in an image block has a width attribute; if its value is less than 840, return.
|
||||||
|
if ( '.wp-block-image img' === param && element.is( '[width]' ) && element.attr( 'width' ) < 840 ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
element.addClass( 'below-entry-meta' );
|
element.addClass( 'below-entry-meta' );
|
||||||
|
|
||||||
if ( caption.hasClass( 'wp-caption' ) ) {
|
if ( caption.hasClass( 'wp-caption' ) ) {
|
||||||
caption.addClass( 'below-entry-meta' );
|
caption.addClass( 'below-entry-meta' );
|
||||||
caption.removeAttr( 'style' );
|
caption.removeAttr( 'style' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( figcaption ) {
|
||||||
|
figcaption.addClass( 'below-entry-meta' );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
} else {
|
} else {
|
||||||
@ -190,11 +201,13 @@
|
|||||||
resizeTimer = setTimeout( function() {
|
resizeTimer = setTimeout( function() {
|
||||||
belowEntryMetaClass( 'img.size-full' );
|
belowEntryMetaClass( 'img.size-full' );
|
||||||
belowEntryMetaClass( 'blockquote.alignleft, blockquote.alignright' );
|
belowEntryMetaClass( 'blockquote.alignleft, blockquote.alignright' );
|
||||||
|
belowEntryMetaClass( '.wp-block-image img' );
|
||||||
}, 300 );
|
}, 300 );
|
||||||
onResizeARIA();
|
onResizeARIA();
|
||||||
} );
|
} );
|
||||||
|
|
||||||
belowEntryMetaClass( 'img.size-full' );
|
belowEntryMetaClass( 'img.size-full' );
|
||||||
belowEntryMetaClass( 'blockquote.alignleft, blockquote.alignright' );
|
belowEntryMetaClass( 'blockquote.alignleft, blockquote.alignright' );
|
||||||
|
belowEntryMetaClass( '.wp-block-image img' );
|
||||||
} );
|
} );
|
||||||
} )( jQuery );
|
} )( jQuery );
|
||||||
|
Loading…
Reference in New Issue
Block a user