Cause
The caption may contain HTML which is causing the attribute to close sooner than it needs to and cause the page to render in an undesired.
Solution
We need the caption, but with any HTML tags stripped out and appropriate characters converted to HTML attributes.
There are two options:
Use the theme operator
{PhotoAlt}
. This is a HTML-safe version of the caption.Use the theme variable transformation
Plaintext
.{Caption}
would be come{PlaintextCaption}
. This is identical to the first option, but handy to show in case we need to use a different theme operator.
But, but... the OP already answered?
The current solution may fail under certain circumstances. If the caption was to contain any single quotes, 'hello'
, then the issue would present itself again.
References