diff options
| author | Michael Peter Christen <mc@yacy.net> | 2026-01-03 02:55:13 +0100 |
|---|---|---|
| committer | Michael Peter Christen <mc@yacy.net> | 2026-01-03 02:55:13 +0100 |
| commit | e2d0050a1c15df8fda56edb5bc559d84149e6633 (patch) | |
| tree | 86c90e82408efad8993108c1b5bcb2028b51514e /source/net | |
| parent | 5645c3c55deba7a15033ee3d13c173eac44877d8 (diff) | |
Fix image preview licensing and show 20 images per page, fixes
https://github.com/yacy/yacy_search_server/issues/438
Use separate one‑time licenses for image thumbnails and full previews to
prevent preview failures after thumbnail loads, and set the Images tab
to request 20 results by default via the content‑domain switch form.
Diffstat (limited to 'source/net')
| -rw-r--r-- | source/net/yacy/htroot/yacysearch.java | 4 | ||||
| -rw-r--r-- | source/net/yacy/htroot/yacysearchitem.java | 26 |
2 files changed, 19 insertions, 11 deletions
diff --git a/source/net/yacy/htroot/yacysearch.java b/source/net/yacy/htroot/yacysearch.java index fa1e452bd..dbe77d1ec 100644 --- a/source/net/yacy/htroot/yacysearch.java +++ b/source/net/yacy/htroot/yacysearch.java @@ -256,6 +256,7 @@ public class yacysearch { // check an determine items per page (max of [100 or configured default]} final int defaultItemsPerPage = sb.getConfigInt(SwitchboardConstants.SEARCH_ITEMS, 10); + final boolean itemsPerPageExplicit = post != null && (post.containsKey("maximumRecords") || post.containsKey("count") || post.containsKey("rows")); int itemsPerPage = post.getInt("maximumRecords", post.getInt("count", post.getInt("rows", defaultItemsPerPage))); // requested or default // SRU syntax with old property as alternative // whatever admin has set as default, that's always ok if (itemsPerPage > defaultItemsPerPage && itemsPerPage > 100) { // if above hardcoded 100 limit restrict request (except default allows more) @@ -301,6 +302,9 @@ public class yacysearch { // find search domain final Classification.ContentDomain contentdom = post == null || !post.containsKey("contentdom") ? ContentDomain.ALL : ContentDomain.contentdomParser(post.get("contentdom", "all")); + if (contentdom == ContentDomain.IMAGE && itemsPerPage == defaultItemsPerPage) { + itemsPerPage = 20; + } // Strict/extended content domain constraint : configured setting may be overriden by request param final boolean strictContentDom = !Boolean.FALSE.toString().equalsIgnoreCase(post.get("strictContentDom", diff --git a/source/net/yacy/htroot/yacysearchitem.java b/source/net/yacy/htroot/yacysearchitem.java index d488480f6..28a7ecac9 100644 --- a/source/net/yacy/htroot/yacysearchitem.java +++ b/source/net/yacy/htroot/yacysearchitem.java @@ -783,28 +783,32 @@ public class yacysearchitem { final String imageUrlExt = MultiProtocolURL.getFileExtension(image.imageUrl.getFileName()); final String target = sb.getConfig(imageUrlstring.matches(target_special_pattern) ? SwitchboardConstants.SEARCH_TARGET_SPECIAL : SwitchboardConstants.SEARCH_TARGET_DEFAULT, "_self"); - final String license = URLLicense.aquireLicense(image.imageUrl); // this is just the license key to get the image forwarded through the YaCy thumbnail viewer, not an actual lawful license + String license = ""; // this is just the license key to get the image forwarded through the YaCy thumbnail viewer, not an actual lawful license /* Image format ouput for ViewImage servlet : default is png, except with gif and svg images */ final String viewImageExt = !imageUrlExt.isEmpty() && ImageViewer.isBrowserRendered(imageUrlExt) ? imageUrlExt : "png"; /* Thumb URL */ - final StringBuilder thumbURLBuilder = new StringBuilder("ViewImage.").append(viewImageExt).append("?maxwidth=") + final StringBuilder thumbURLBuilder = new StringBuilder("ViewImage.").append(viewImageExt).append("?maxwidth=") .append(DEFAULT_IMG_WIDTH).append("&maxheight=").append(DEFAULT_IMG_HEIGHT) .append("&isStatic=true&quadratic"); /* Only use licence code for non authentified users. For authenticated users licence would never be released and would unnecessarily fill URLLicense.permissions. */ + final String thumbURL; + final String fullPreviewURL; if(fullViewingRights) { thumbURLBuilder.append("&url=").append(imageUrlstring); + thumbURL = thumbURLBuilder.toString(); + /* Full size preview URL */ + fullPreviewURL = "ViewImage." + viewImageExt + "?isStatic=true&url=" + imageUrlstring; } else { - thumbURLBuilder.append("&code=").append(URLLicense.aquireLicense(image.imageUrl)); + final String thumbLicense = URLLicense.aquireLicense(image.imageUrl); + final String fullPreviewLicense = URLLicense.aquireLicense(image.imageUrl); + final String baseThumbURL = thumbURLBuilder.toString(); + thumbURL = baseThumbURL + "&code=" + thumbLicense; + license = thumbLicense; + /* Not authenticated : full preview URL must be the same as thumb URL, but with a separate one-time license */ + fullPreviewURL = baseThumbURL + "&code=" + fullPreviewLicense; } - final String thumbURL = thumbURLBuilder.toString(); prop.putHTML("content_item_hrefCache", thumbURL); - /* Full size preview URL */ - if(fullViewingRights) { - prop.putHTML("content_item_hrefFullPreview", "ViewImage." + viewImageExt + "?isStatic=true&url=" + imageUrlstring); - } else { - /* Not authenticated : full preview URL must be the same as thumb URL */ - prop.putHTML("content_item_hrefFullPreview", thumbURL); - } + prop.putHTML("content_item_hrefFullPreview", fullPreviewURL); prop.putHTML("content_item_href", imageUrlstring); prop.putHTML("content_item_target", target); prop.put("content_item_code", license); |
