**Subject:** Bug Report: Unwanted HTML Output in XML Sitemap due to Output Buffering Issue
**Hello,**
I have encountered an issue with the **Responsive Lightbox – Inline Gallery** plugin that affects the XML sitemap generated by Yoast SEO.
### **Issue Description:**
The plugin outputs unwanted HTML (</div></div>) into the sitemap, causing an XML parsing error. The problem is located in the file:
📂 **/responsive-lightbox-inline-gallery/includes/class-frontend.php**
The issue occurs because ob_start(); is used, but the buffer is not correctly cleaned before WordPress processes its output.
### **Problematic Code:**
`php
ob_start(); ?>
<div class=”rl-gallery-container<?php echo apply_filters( ‘rl_gallery_container_class’, ”, $atts, $rl_gallery_id ); ?>” id=”rl-gallery-container-<?php echo $gallery_no; ?>” data-gallery_id=”<?php echo $rl_gallery_id; ?>”>
<?php do_action( ‘rl_before_gallery’, $atts, $rl_gallery_id ); ?>
<div class=”rl-gallery rl-inline-gallery <?php echo $atts[‘class’]; ?>” id=”rl-gallery-<?php echo $gallery_no; ?>” data-gallery_no=”<?php echo $gallery_no; ?>”>
<?php foreach ( $images as $image ) {
echo preg_replace( ‘/(<a[^>]*? class=(?:\’|”))(.+?)((?:\’|”).*?>)/s’, ‘${1}${2} rl-gallery-item${3}’, $image[‘link’] );
} ?>
</div>
<?php do_action( ‘rl_after_gallery’, $atts, $rl_gallery_id ); ?>
</div>
<?php $gallery_html = ob_get_contents();
ob_clean();
`
### **Suggested Fix:**
Replace:
`php
$gallery_html = ob_get_contents();
ob_clean();
`
With:
`php
$gallery_html = ob_get_clean();
`
**Why?**
– ob_get_clean(); correctly retrieves the buffered content and clears the buffer, ensuring no unwanted HTML remains in WordPress output.
– ob_clean(); does not properly clear all output in some cases, leaving stray HTML that affects Yoast SEO’s XML sitemap.
### **Alternative Fix (Without Output Buffering):**
If ob_start(); is unnecessary, replace it with direct string concatenation to $gallery_html:
`php
$gallery_html = ‘<div class=”rl-gallery-container’ . apply_filters( ‘rl_gallery_container_class’, ”, $atts, $rl_gallery_id ) . ‘” id=”rl-gallery-container-‘ . $gallery_no . ‘” data-gallery_id=”‘ . $rl_gallery_id . ‘”>’ .
do_action( ‘rl_before_gallery’, $atts, $rl_gallery_id ) .
‘<div class=”rl-gallery rl-inline-gallery ‘ . $atts[‘class’] . ‘” id=”rl-gallery-‘ . $gallery_no . ‘” data-gallery_no=”‘ . $gallery_no . ‘”>’;
foreach ( $images as $image ) {
$gallery_html .= preg_replace( ‘/(<a[^>]*? class=(?:\’|”))(.+?)((?:\’|”).*?>)/s’, ‘${1}${2} rl-gallery-item${3}’, $image[‘link’] );
}
$gallery_html .= ‘</div>’ .
do_action( ‘rl_after_gallery’, $atts, $rl_gallery_id ) .
‘</div>’;
`
This would completely remove the need for output buffering.
### **Conclusion:**
Please update the plugin with ob_get_clean(); to prevent unexpected HTML output in XML sitemaps. This issue affects SEO and can break sitemap indexing.
Let me know if you need more details.
**Best regards,**
Jérôme