admin管理员组

文章数量:1122832

I want to add the 'wp-caption' class to the figure element only if the image has caption. How do I do that? I'm using the new gutenberg enviroment, if that affects anything.

for example:

form this:

<figure class="alignleft"> <img src="#" alt="#"/> <figcaption>Test</figcaption> </figure>

to this:

<figure class="alignleft wp-caption"> <img src="#" alt="#"/> <figcaption>Test</figcaption> </figure>

so the wp-caption class was added to figure, because the image has caption.

Thank You

本文标签: filtersHow to add custom classes to figure element only if image has caption