-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Output class indicating whether an image has a caption #10445
Comments
Aside: Can we just take a moment to appreciate the colour palette of these labels |
Although the change is fairly straightforward it requires the In the meantime it's possible to add the class using a small bit of client-side JS: document.querySelectorAll('figure.kg-card').forEach(function (figure) {
if (figure.querySelector('figcaption')) {
figure.classList.add('kg-card-hascaption');
}
}); Or maybe document.querySelectorAll('figure.kg-card figcaption').forEach(function (figcaption) {
figcaption.closest('figure').classList.add('kg-card-hascaption');
}); |
@kevinansfield That's fine. How would I trigger manual re-generation? Just update a post? |
…ptions refs #10445 - adds class to card renderers - class will only be present on new or re-saved posts
@JohnONolan the change is now in master so new/re-saved posts will start having the class after the next release. I've added the full migration to our 3.0 tracking list so I'll close this now. |
refs TryGhost#10445 - re-generates HTML for every post so that they are using the most recent Koenig renderer output
refs #10445 - re-generates HTML for every post so that they are using the most recent Koenig renderer output
…ptions refs TryGhost/Ghost#10445 - adds class to card renderers - class will only be present on new or re-saved posts
I think I have a reasonable case for adding a class of
.kg-card-hascaption
conditionally to a parent card wrapper, when it has a caption.Example:
In this example I'm trying to achieve different layouts for different image sizes. The first image is
width-full
- where the figcaption overlaid with position absolute. Easy.The second image is
width-wide
- which I'm trying to style so that it has room for a caption somewhere around it.After a solid hour or two, though, I don't think this is going to be doable without a class on the parent. I've cycled through absolute, flexbox, grid, and table display modes - and all of them get you close, but none of them can account for a layout which automatically adapts to whether or not a caption is present.
Short version: All the layout modes require setting fixed proportions to manually "make space" for the caption, with the exception of flexbox -- and flexbox has a bug which destroys image aspect ratio when an
img
is a flex-child.So I think the only way to reasonably achieve this for the parent to specify whether it has a caption, which would open up far, far more options for how to display images with captions.
An additional benefit here would be that we'd actually double the number of available image styles/sizes, because every size can have a unique appearance with/without caption - which also opens up a lot more flexibility in terms of design.
TLDR: I think cards should output an additional class based on whether or not they contain a caption
/cc @peterzimon @kevinansfield
The text was updated successfully, but these errors were encountered: