Forum
html missing
I have this markup in one of my templates:
<div class="main-img">
<!-- Link to page -->
<perch:if exists="link">
<a href="<perch:content id="link" type="text" label="Link for Image - (page-name.php or https://...) or leave blank" />">
</perch:if>
<!-- Image upload -->
<img src="<perch:content id="right-col-img" type="image" label="Right Column Image" />" alt="<perch:content id="title" type="text" label="Alt Tag (For SEO and Accessibility)" />" /></a>
<!-- Image caption link-->
<perch:if exists="captionlink">
<a class="caption" id="caption" href="<perch:content id="captionlink" type="text" label="Link for Caption - (page-name.php or https://...) or leave blank" />">
</perch:if>
<!-- Image caption -->
<perch:content type="text" label="Image Caption (if required)" /></a>
</div>
I need to be able to add a caption that can be a link, but only if required. This solution here doesn't seem right and it doesn't even produce any markup for the caption, although the caption does appear!
How can I do this better?
Thanks
Your caption field is missing an ID.
Thanks Ive fixed that, but its producing this markup:
I cant target the caption for styling because the <a> tag is not outputting (because its being shared by 'image caption link' and 'image caption'...?
I cant figure out how to combine the two.
You could do something more like:
Thanks Drew. I've replaced the caption section with your suggestion but the caption renders without its <a> tags still!
??
I tell a lie. Seems to be working fine now. Thanks!