#wordpress 2022-09-27

2022-09-27 UTC
#
ludovicchabant
Frankly I don’t know if it would be such a bad idea to add the u-photo class to every image in every post — if the author went through the trouble of adding a photo, it’s not for nothing
#
ludovicchabant
But yeah I might have to look into the special Wordpress post formats (photo, gallery, etc) and only enable it there, if only because that may be the only way to actually get something working
#
gRegor
It's caused issues in the past to do that, so we recommend against it. There's a difference between a photo post, where the primary content is a photo/image, vs an article that may include several photos. See https://indieweb.org/photo and https://indieweb.org/post-type-discovery#Algorithm
#
gRegor
E.g. if every photo had `u-photo`, a social reader like Monocle would highlight those photos as the main content, then show text under it, like a caption, which probably isn't the author's intent.
#
ludovicchabant
I see, thanks
[Murray]1, [tw2113_Slack_]1, RasAlGhoul, RasAlGhoul_ and jacky_ joined the channel
#
ludovicchabant
Ok so I have something that vaguely works using that custom class hook for post thumbnails (aka featured images) but of course that only works for one photo
#
ludovicchabant
I’m not sure what to do for multiple photos (similar to a tweet with up to 4 images). The “gallery” post format would ideally work for this — I need to look into whether there’s a hook for gallery blocks
jsbach, gRegorLove_, gRegor, fef, angelo, RasAlGhoul and jacky joined the channel
#
ludovicchabant
After some more fiddling around, I found another way to do it: register a callback for the `wp_content_img_tag` hook, which runs on the final content of a post/page, but only for the images found in there. In the callback I can check `get_post_format()` to see if the post is a "photo" or "gallery" post. If so, I add the `u-photo` class using some lame string replacement.
#
ludovicchabant
This works for photos added via various ways, whether it was an image block, a gallery block, a shortcode, raw HTML, whatever.
jacky, fef and angelo joined the channel