I'm encountering a strange issue with a conditional comparison involving the caption of a featured image. Here is my code, which checks whether the featured image caption is empty:
The problem is that if the caption contains one or more double-quotes, the comparison fails. I've added the debug="true" component to the conditional statement, but it doesn't display additional information as it ought to (a separate failure in itself). Note: without a quote in the caption, the debug argument does display the gray box with additional information.
Does this have to do with the fact that the quoted value has quotes in it? Is there a way to escape the quotes in the caption so that Toolset doesn't get confused?
The condition itself and the debug info are both being tripped up by the quotes, yes.
There isn't a way to escape the output directly, you'd need to set this up yourself, using the PHP function htmlspecialchars (hidden link).
I haven't tried, but you could register that function at Toolset > Settings > Front-end Content and then simply wrap your existing shortcode in that function within the if attribute.
If that doesn't work, you may have to register a custom shortcode that returns the caption with the quotes replaced by html entities.
Thanks, Nigel and Luo. The conditional just needs to test for the presence of text in the image's caption field, so I'll create a custom shortcode that returns true or false.