resolver.resolveUnquotedPolicyExpression(
imageComponentName, PolicyType.IMAGE);
AssetResolver assetResolver = pageContext.getAssetResolver();
SelectedVariant selected =
assetResolver.selectBestVariant(reference, null);
// Try and find the best image asset with the specified name.
if (selected != null) {
ImageAsset imageAsset =
(ImageAsset) selected.getOldObject();
if (imageAsset == null) {
// No image asset which matches could be found so use the
// alt text, if any.
// And then try and write out the alt or fallback text,
// if we can
AltTextAttributes altTextAttrs =
new AltTextAttributes(attributes);
altTextAttrs.setStyles(pattributes.getStyles());
altText = new FallbackComponentTextAssetReference(
assetResolver, selected.getPolicy(), altText);
altTextAttrs.setAltText(altText);
if (protocol.writeAltText(altTextAttrs)) {
return SKIP_ELEMENT_BODY;
}
} else {
String[] srcArray = pageContext.
retrieveImageAssetURLAsString(imageAsset);
url = srcArray[0];
AssetGroup assetGroup =
assetResolver.getAssetGroup(imageAsset);
if (assetGroup != null) {
pattributes.setLocalSrc(AssetGroup.ON_DEVICE ==
assetGroup.getLocationType());
} else {
pattributes.setLocalSrc(false);
}
// Make a note of whether this image is a convertible
// image asset
if (imageAsset instanceof ConvertibleImageAsset) {
pattributes.setConvertibleImageAsset(true);
} else {
pattributes.setConvertibleImageAsset(false);
}
pattributes.setHeight(StringConvertor.
valueOf(imageAsset.getPixelsY()));
pattributes.setWidth(StringConvertor.
valueOf(imageAsset.getPixelsX()));
ImageMetaData metadata = (ImageMetaData) selected.getVariant().getMetaData();
if (ImageConversionMode.ALWAYS_CONVERT ==
metadata.getConversionMode()) {
PixelDimensionsMetaData dimMetaData =
(PixelDimensionsMetaData) selected
.getVariant().getMetaData();
// save height and width in pixels unit to object's parameter map
if (dimMetaData.getHeight() != 0) {
pattributes.setHeight(StringConvertor.valueOf(dimMetaData