// from Builder public Media createMedia(MediaDesc md, Pages page, Args args) { // start with the anchor _html.reset().open("a", "href", link(page, args), "style", A_STYLE); if (!md.isImage()) { // don't bother with other media types, just use some fakey text // TODO: should we worry about this? I don't think I've ever seen any non-image // media in my feed before... return new StringWrapper(_html.append("[X]").finish()); } if (md instanceof HashMediaDesc) { md = MediaDescFactory.createMediaDesc( (HashMediaDesc) md, (int) (Calendars.now().addYears(1).toTime() / 1000)); } int size = MediaDescSize.HALF_THUMBNAIL_SIZE; if (page == Pages.WORLD && args.get(0, "").startsWith("s")) { // snapshots are unconstrained at a set size; fake a width constraint for // TINY_SIZE. if (md != null) { md = md.newWithConstraint(MediaDesc.HORIZONTALLY_CONSTRAINED); } size = MediaDescSize.SNAPSHOT_TINY_SIZE; } int width = MediaDescSize.getWidth(size); int height = MediaDescSize.getHeight(size); Dimensions dim = SharedMediaUtil.resolveImageSize(md, width, height); if (dim == null) { dim = new Dimensions(width + "px", height + "px"); } return new StringWrapper( _html.open("img", "src", md.getMediaPath(), "style", imgStyle(dim)).finish()); }