detect base64 imagein HTML

public bool detectImgBase64(string bodyHtml) { bool hasImageBase64 = false; foreach (Match m in Regex.Matches(bodyHtml, "<img.+?src=[\"'](.+?)[\"'].+?>", RegexOptions.IgnoreCase | RegexOptions.Multiline)) { string src = m.Groups[1].Value; if (src.StartsWith("data:image/png;base64") || src.StartsWith("data:image/jpeg;base64") || src.StartsWith("data:image/gif;base64") || src.StartsWith("data:image/png;base64") || src.StartsWith("data:image/bmp;base64") || src.StartsWith("data:image/icon;base64") ) { hasImageBase64 = true; break; } } return hasImageBase64; }
Detect if a html string contains base 64 image

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.