Update Post.php

This commit is contained in:
charlesteh
2023-10-03 12:59:43 +08:00
committed by GitHub
parent af3e4d12c6
commit a7f1752be3

View File

@@ -170,12 +170,19 @@ public function getHtmlBodyAttribute()
$figureElement->appendChild($imgElement);
$figureElement->setAttribute('class', 'image');
// Create a new <footer> element inside <figure>
$footerElement = new \DOMElement('footer', $imgElement->getAttribute('alt'));
// Create a new <footer> element inside <figure> without directly setting its content
$footerElement = $imgElement->ownerDocument->createElement('footer');
$figureElement->appendChild($footerElement);
// Add the content to <footer> using createTextNode to ensure special characters are handled
$footerText = $imgElement->ownerDocument->createTextNode($imgElement->getAttribute('alt'));
$footerElement->appendChild($footerText);
// Set the class attribute for <footer>
$footerElement->setAttribute('class', 'image-caption');
});
// Add Bootstrap 5 styling to tables
$crawler->filter('table')->each(function (Crawler $node) {
$tableElement = $node->getNode(0);