Hi,
Here we are going to learn how to get an Image URL from a RichTextArea if someone adds an image in RichTextArea.
String decodedImageUrl;
Matcher imgMatcher = Pattern.compile( '<img(.+?)>' ).matcher(<RichTextArea_FieldAPIName>);
// iterate each image tag found
while ( imgMatcher.find() ) {
// get the image tag html
String imageTag = imgMatcher.group();
System.debug( 'imageTag=' + imageTag );
String imageURL = imageTag.substringBetween( ' src="', '"' );
System.debug( 'imageURL=' + imageURL );
decodedImageUrl= imageURL.unescapeHtml4();
}
Reference:
No comments:
Post a Comment