Skip to content

Commit

Permalink
Merge pull request #2 from DasBen/non-existing-figcaption
Browse files Browse the repository at this point in the history
Non existing figcaption was not supported
  • Loading branch information
DasBen authored Mar 29, 2022
2 parents edc8501 + ba3f213 commit 66d06d0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion casualben-automatic-alt-and-caption-text.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: CasualBen Automatic Alt and Caption Text
* Plugin URI: https://github.com/DasBen/CasualBen-Automatic-Alt-And-Caption-Text
* Description: Automatically adds alt text and captions to images in Gutenberg block editor when you add or modify in the Media Library
* Version: 1.1.0
* Version: 1.1.1
* Author: Benjamin Pahl - CasualBen
* Author URI: https://www.casual-ben.com
*
Expand All @@ -30,6 +30,8 @@
// Update Caption
$caption = wp_get_attachment_caption($block['attrs']['id']);
if (!empty($caption)) {
$content = str_replace("</figure>", "<figcaption>".$caption."</figcaption></figure>", $content);
} else {
$content = preg_replace('/<figcaption>.*<\/figcaption>/', '<figcaption>' . $caption . '</figcaption>', $content);
}
}
Expand Down

0 comments on commit 66d06d0

Please sign in to comment.