@Override
public int doEndTag() throws JspException {
final ServletRequest request = pageContext.getRequest();
MediaThumbnail thumbnail;
if (request.getAttribute("content") != null
&& request.getAttribute("content") instanceof MediaContent) {
thumbnail = ((MediaContent) request.getAttribute("content")).addExtension(MediaConstants.THUMBNAIL);
} else if (request.getAttribute("group") != null
&& request.getAttribute("group") instanceof MediaGroup) {
thumbnail = ((MediaGroup) request.getAttribute("group")).addExtension(MediaConstants.THUMBNAIL);
} else if (request.getAttribute("entry") != null
&& request.getAttribute("entry") instanceof Entry) {
thumbnail = ((Entry) request.getAttribute("entry")).addExtension(MediaConstants.THUMBNAIL);
} else {
thumbnail = ((Feed) request.getAttribute("feed")).addExtension(MediaConstants.THUMBNAIL);
}
// set the scheme
thumbnail.setUrl(url.replaceAll(" ", "%20"));
if (width != 0) thumbnail.setWidth(width);
if (height != 0) thumbnail.setHeight(height);
if (time != null) thumbnail.setTime(time);
return super.doEndTag();
}