- A · M
- No. It isn't marked as a caption in the source code and I'm not going to compare it to some hidden fallback attributes. There is no __actual__ caption shown on the original page, why should I set it? If the editors of the website wanted to make a caption, they should have been more careful when doing it.
- Type of issue
- IV page is missing essential content
- Mar 29, 2019
It is possible to reliably identify image captions.
In the source:
<img data-caption="CAPTION TEXT">
then replace <p> with <figure> and wrap ./text() in <figcaption>
In practice, it is implemented a little more difficult.
It is necessary to convert @ data-caption to text before comparison. You can also check if <p> have other children.
It works great in my template.
The solution is reliable because:
1. Where there is no signature to the image, it will not be in IV.
Despite the fact that the text is in @data-caption
2. If the paragraph contains another text (not a figcaption) - it will not be lost
3. It is hardly possible to imagine a situation when this approach does not work.