fix appearance of image search thumbnails.

pull/1/head
orbiter 11 years ago
parent 6daae59479
commit ce1dbfeb0f

@ -21,6 +21,7 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import java.awt.Container;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.MediaTracker;
import java.awt.image.BufferedImage;
@ -72,6 +73,7 @@ public class ViewImage {
String urlString = post.get("url", "");
final String urlLicense = post.get("code", "");
final boolean quadratic = post.containsKey("quadratic");
final boolean auth = Domains.isLocalhost(header.get(HeaderFramework.CONNECTION_PROP_CLIENTIP, "")) || sb.verifyAuthentication(header); // handle access rights
DigestURL url = null;
@ -146,6 +148,23 @@ public class ViewImage {
// find original size
final int h = image.getHeight(null);
final int w = image.getWidth(null);
// if a quadratic flag is set, we cut the image out to be in quadratic shape
if (quadratic && w != h) {
if (w > h) {
final BufferedImage dst = new BufferedImage(h, h, BufferedImage.TYPE_INT_RGB);
Graphics2D g = dst.createGraphics();
g.drawImage(image, 0, 0, h - 1, h - 1, (w - h) / 2, 0, h + (w - h) / 2, h - 1, null);
g.dispose();
image = dst;
} else {
final BufferedImage dst = new BufferedImage(w, w, BufferedImage.TYPE_INT_RGB);
Graphics2D g = dst.createGraphics();
g.drawImage(image, 0, 0, w - 1, w - 1, 0, (h - w) / 2, w - 1, w + (h - w) / 2, null);
g.dispose();
image = dst;
}
}
// in case of not-authorized access shrink the image to prevent
// copyright problems, so that images are not larger than thumbnails

@ -37,9 +37,9 @@
</div>
::
#(item)#::<div class="thumbcontainer">
<a href="#[hrefCache]#" target="#[target]#" class="thumblink" onclick="return hs.expand(this)">
<a href="#[href]#" target="#[target]#" class="thumblink" onclick="return hs.expand(this)">
<!-- <img src="ViewImage.png?maxwidth=128&amp;maxheight=128&amp;code=#[code]#" alt="#[name]#" /> -->
<img src="#[href]#" width="128" height="128" alt="#[name]#" />
<img src="#[hrefCache]#" width="128" height="128" alt="#[name]#" />
</a>
<div class="highslide-caption"><a href="#[href]#" target="#[target]#">#[name]#</a><br /><a href="#[source]#" target="#[target]#">#[sourcedom]#</a></div>
<!--

@ -35,7 +35,6 @@ import net.yacy.cora.document.feed.RSSMessage;
import net.yacy.cora.document.id.DigestURL;
import net.yacy.cora.document.id.MultiProtocolURL;
import net.yacy.cora.protocol.ClientIdentification;
import net.yacy.cora.protocol.Domains;
import net.yacy.cora.protocol.HeaderFramework;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.cora.protocol.RequestHeader.FileType;
@ -62,7 +61,6 @@ import net.yacy.server.serverSwitch;
import net.yacy.utils.crypt;
import net.yacy.utils.nxTools;
public class yacysearchitem {
private static final String SHORTEN_SUFFIX = "...";
@ -79,7 +77,6 @@ public class yacysearchitem {
final String eventID = post.get("eventID", "");
final boolean authenticated = sb.adminAuthenticated(header) >= 2;
final int item = post.getInt("item", -1);
final boolean auth = Domains.isLocalhost(header.get(HeaderFramework.CONNECTION_PROP_CLIENTIP, "")) || sb.verifyAuthentication(header);
final RequestHeader.FileType fileType = header.fileType();
// default settings for blank item
@ -279,7 +276,7 @@ public class yacysearchitem {
final String license = URLLicense.aquireLicense(image.imageUrl);
sb.loader.loadIfNotExistBackground(image.imageUrl, 1024 * 1024 * 10, null, ClientIdentification.yacyIntranetCrawlerAgent);
prop.putHTML("content_item_hrefCache", (auth) ? "/ViewImage.png?url=" + imageUrlstring : imageUrlstring);
prop.putHTML("content_item_hrefCache", "/ViewImage.png?maxwidth=128&maxheight=128&quadratic=&url=" + imageUrlstring);
prop.putHTML("content_item_href", imageUrlstring);
prop.putHTML("content_item_target", target);
prop.put("content_item_code", license);

Loading…
Cancel
Save