• Resolved BasTaller

    (@bastaller)


    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 6 years, 9 months ago by BasTaller.
    • This topic was modified 6 years, 9 months ago by BasTaller.
    • This topic was modified 6 years, 9 months ago by BasTaller.
    • This topic was modified 6 years, 9 months ago by BasTaller.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Proposal for the best replacement in single images’ is closed to new replies.