Title: Proposal for the best replacement in single images
Last modified: February 24, 2018

---

# Proposal for the best replacement in single images

 *  Resolved [BasTaller](https://wordpress.org/support/users/bastaller/)
 * (@bastaller)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/proposal-for-best-replacement/)
 * Imagine a use-case. Sometimes images are inserted into the content, and then 
   the title is edited via the WYSIWYG editor (not from the media uploader). Later,
   these images will be autowrapped with the <figure> tag, with applied <figcaption
   > to it. In this case, the plugin doesn’t use the correct values, replacing them
   with default ones.
 * Here’s the improvement:
 *     ```
       	@$document->loadHTML($content, LIBXML_NOWARNING);
   
       	if( !$document ) {
       		return $content;
       	}
       	/* !!!!!!!!!!!!!!!! start of insertion */
       	$figTags = $document->getElementsByTagName('figure');
       	foreach ($figTags as $tag){
       		$caption = $tag->nodeValue;
       		$imgTags = $tag->getElementsByTagName('img');
       		foreach ($imgTags as $tag) {
       			$tag->setAttribute('title', $caption);
       		}
       	}
       	/* !!!!!!!!!!!!!!!! end of insertion */
       ```
   
    -  This topic was modified 8 years, 2 months ago by [BasTaller](https://wordpress.org/support/users/bastaller/).
    -  This topic was modified 8 years, 2 months ago by [BasTaller](https://wordpress.org/support/users/bastaller/).
    -  This topic was modified 8 years, 2 months ago by [BasTaller](https://wordpress.org/support/users/bastaller/).
    -  This topic was modified 8 years, 2 months ago by [BasTaller](https://wordpress.org/support/users/bastaller/).

Viewing 1 replies (of 1 total)

 *  Plugin Author [PascalBajorat](https://wordpress.org/support/users/pascalbajorat/)
 * (@pascalbajorat)
 * [8 years ago](https://wordpress.org/support/topic/proposal-for-best-replacement/#post-10199975)
 * Thank you, this will be included with the next update.

Viewing 1 replies (of 1 total)

The topic ‘Proposal for the best replacement in single images’ is closed to new 
replies.

 * ![](https://s.w.org/plugins/geopattern-icon/pb-seo-friendly-images_3e4a5e.svg)
 * [PB SEO Friendly Images](https://wordpress.org/plugins/pb-seo-friendly-images/)
 * [Support Threads](https://wordpress.org/support/plugin/pb-seo-friendly-images/)
 * [Active Topics](https://wordpress.org/support/plugin/pb-seo-friendly-images/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/pb-seo-friendly-images/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/pb-seo-friendly-images/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [PascalBajorat](https://wordpress.org/support/users/pascalbajorat/)
 * Last activity: [8 years ago](https://wordpress.org/support/topic/proposal-for-best-replacement/#post-10199975)
 * Status: resolved