Can you confirm that Hybrid Core is converting the default markup for images with captions, to use the <figure> element? And that it is also adding an inline style for width? If so, I’d like to remove the inline width. (I love the markup change, though :-))
Here’s the markup that I’m seeing when inserting an image with a caption:
Thanks. I actually didn’t get that to work, but you made a good point about needing a width of some kind. I didn’t realize that removing it (or setting width: auto;) would jack up longer captions on relatively smaller images.
I ended up using the cleaner caption extension that you used on the Stargazer theme. max-width works perfectly while also keeping the images responsive.
And just FYI… I LOVE your approach to code. And really appreciate all that you do for the WP community.
It might help if I provide a little context to my surrounding code…
I applied this base CSS to all images & figures:
img, figure {
max-width: 100%;
height: auto;
}
With the above styles applied, as long as you don’t apply a margin to the <figure> element, the image is still responsive, even when using core’s native inline width on the <figure>.
My problem is the way I’ve chosen to setup the spacing for my .entry-content div. Because I want certain elements to fill up 100% of the browser on smaller screens, I have no left/right margin or padding on .entry-content. Instead, I’m using a left/right margin on selected elements within .entry-content, at certain breakpoints:
The addition of a left or right margin on the <figure> element, combined with an inline width, allows the image to overflow the .entry-content div. But using max-width keeps the image contained.
If I can help out in any way, test certain scenarios, etc., please let me know.
Justin,
Can you confirm that Hybrid Core is converting the default markup for images with captions, to use the
<figure>
element? And that it is also adding an inline style for width? If so, I’d like to remove the inline width. (I love the markup change, though :-))Here’s the markup that I’m seeing when inserting an image with a caption:
Is Hybrid Core grabbing the true width of the image and inserting an inline style based on that?
As of HC 3.0, the framework no longer filters the caption because this is now built into WordPress. You can remove it with this filter though:
`
add_filter( ‘img_caption_shortcode_width’, ‘__return_zero’ );
`
The inline style is needed though to handle the variable width of the image.
Thanks. I actually didn’t get that to work, but you made a good point about needing a width of some kind. I didn’t realize that removing it (or setting
width: auto;
) would jack up longer captions on relatively smaller images.I ended up using the cleaner caption extension that you used on the Stargazer theme.
max-width
works perfectly while also keeping the images responsive.And just FYI… I LOVE your approach to code. And really appreciate all that you do for the WP community.
I actually didn’t realize that core set `width` instead of `max-width`. If I had realized that, I might not have removed Cleaner Caption.
I might need to re-add something because I remember `max-width` being a better option in some cases.
I would agree that
max-width
is the way to go.It might help if I provide a little context to my surrounding code…
I applied this base CSS to all images & figures:
With the above styles applied, as long as you don’t apply a margin to the
<figure>
element, the image is still responsive, even when using core’s native inline width on the<figure>
.My problem is the way I’ve chosen to setup the spacing for my
.entry-content
div. Because I want certain elements to fill up 100% of the browser on smaller screens, I have no left/right margin or padding on.entry-content
. Instead, I’m using a left/right margin on selected elements within.entry-content
, at certain breakpoints:The addition of a left or right margin on the
<figure>
element, combined with an inlinewidth
, allows the image to overflow the.entry-content
div. But usingmax-width
keeps the image contained.If I can help out in any way, test certain scenarios, etc., please let me know.
Thanks for letting me know. That’ll give me a testing scenario.
I may just re-add the Cleaner Caption extension.
Thanks for letting me know. That’ll give me a testing scenario.
I may just re-add the Cleaner Caption extension.