use of ezvcard.parameter.ImageType in project ez-vcard by mangstadt.
the class ImagePropertyScribe method _parseHtml.
@Override
protected T _parseHtml(HCardElement element, ParseContext context) {
String elementName = element.tagName();
if (!"img".equals(elementName)) {
return super._parseHtml(element, context);
}
String src = element.absUrl("src");
if (src.length() == 0) {
throw new CannotParseException(13);
}
try {
DataUri uri = DataUri.parse(src);
ImageType mediaType = _mediaTypeFromMediaTypeParameter(uri.getContentType());
return _newInstance(uri.getData(), mediaType);
} catch (IllegalArgumentException e) {
// not a data URI
String extension = getFileExtension(src);
ImageType mediaType = (extension == null) ? null : _mediaTypeFromFileExtension(extension);
return _newInstance(src, mediaType);
}
}
Aggregations