return SKIP_BODY;
}
ImageResource image = null;
ImageContent imageContent = null;
ImageStyle style = null;
String linkToImage = null;
int imageWidth = 0;
int imageHeight = 0;
// Try to determine the language
Language language = request.getLanguage();
// Load the content
try {
image = (ImageResource) repository.get(uri);
if (image == null) {
logger.warn("Non existing image {} requested on {}", uri, request.getUrl());
return SKIP_BODY;
}
image.switchTo(language);
Language contentLanguage = null;
contentLanguage = LanguageUtils.getPreferredContentLanguage(image, request, site);
if (contentLanguage == null) {
logger.warn("Image {} does not have suitable content", image);
return SKIP_BODY;
}
imageContent = image.getContent(contentLanguage);
if (imageContent == null)
imageContent = image.getOriginalContent();
imageWidth = imageContent.getWidth();
imageHeight = imageContent.getHeight();
// TODO: Make this a reference rather than a hard coded string
linkToImage = UrlUtils.concat("/weblounge-images", image.getIdentifier(), language.getIdentifier());
} catch (ContentRepositoryException e) {
logger.warn("Error trying to load image " + uri + " on " + request.getUrl() + ": " + e.getMessage(), e);
return SKIP_BODY;
}
// Find the image style
if (StringUtils.isNotBlank(imageStyle)) {
style = ImageStyleUtils.findStyle(imageStyle, site);
if (style != null) {
linkToImage += "?style=" + style.getIdentifier();
imageWidth = ImageStyleUtils.getStyledWidth(imageContent, style);
imageHeight = ImageStyleUtils.getStyledHeight(imageContent, style);
stashAndSetAttribute(ImageResourceTagExtraInfo.STYLE, style);
} else {
logger.warn("Image style '{}' not found to render on {}", imageStyle, request.getUrl());