Move Image Captions Inside Link (<a> tag) if Added

I'm just looking for a relatively simple way to modify the default output when a standard post image with a caption

I'm just looking for a relatively simple way to modify the default output when a standard post image with a caption is linked somewhere (generally to another page), so that the caption is included in the link. It currently resides outside of the link tag so that it doesn't link like the image does.

I'll eventually be moving the caption up so it overlays the image. It's just awkward that the image will link properly to a separate page, but the caption (which will be the title of the page that the link points to) will not.

The default output is currently:

<div id="attachment_xxx" style="width: 480px" class="wp-caption alignnone">
<a href="/about/history-mission/">
<img class="size-medium wp-image-1679" src=".jpg" alt="" width="470" height="313" srcset="[multiple image sizes]" sizes="[proper sizes]">
</a>
<p id="caption-attachment-1679" class="wp-caption-text">History & Mission</p>
</div>
  • Any way to get that p.wp-caption-text to slide into the 'a' tag with the image???

If there is no link added to a photo, it should just behave normally. I also thought about using a gallery, but didn't see a way to make each image a unique link to other pages.

NOTE: For now I'm using the classic editor (w/ TinyMCE Advanced). Not sure if I'll switch to Gutenberg yet, as that would open a TON of possibilities up to the client that I would have to account for & style appropriately. Because, you know, clients...

THANKS!

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745594758a4635042.html

相关推荐

  • Move Image Captions Inside Link (&lt;a&gt; tag) if Added

    I'm just looking for a relatively simple way to modify the default output when a standard post image with a caption

    14小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信