Skip to content

Commit

Permalink
Fix thumbnail issues
Browse files Browse the repository at this point in the history
The issue is partly fixed by the following commits, which are already part of the v6.2 release:
IQSS#10269
IQSS#10258

Had to add "dataset.setUseGenericThumbnail(false);" line in the DatasetServiceBean to make it work.
  • Loading branch information
fintanorbert committed May 17, 2024
1 parent 4d9a25b commit 7121498
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,7 @@ public Dataset setNonDatasetFileAsThumbnail(Dataset dataset, InputStream inputSt
}
dataset = DatasetUtil.persistDatasetLogoToStorageAndCreateThumbnails(dataset, inputStream);
dataset.setThumbnailFile(null);
dataset.setUseGenericThumbnail(false);
return merge(dataset);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;
import edu.harvard.iq.dataverse.dataaccess.DataAccess;
import edu.harvard.iq.dataverse.dataaccess.StorageIO;
import edu.harvard.iq.dataverse.dataset.DatasetUtil;
import java.io.IOException;

import jakarta.ejb.EJB;
import jakarta.enterprise.context.RequestScoped;
Expand Down Expand Up @@ -170,13 +174,25 @@ public String getDatasetCardImageAsUrl(Dataset dataset, Long versionId, boolean

if (thumbnailFile == null) {

// We attempt to auto-select via the optimized, native query-based method
boolean hasDatasetLogo = false;
StorageIO<DvObject> storageIO = null;
try {
storageIO = DataAccess.getStorageIO(dataset);
if (storageIO.isAuxObjectCached(DatasetUtil.datasetLogoFilenameFinal)) {
// If not, return null/use the default, otherwise pass the logo URL
hasDatasetLogo = true;
}
} catch (IOException ioex) {
logger.warning("getDatasetCardImageAsUrl(): Failed to initialize dataset StorageIO for "
+ dataset.getStorageIdentifier() + " (" + ioex.getMessage() + ")");
}
// If no other logo we attempt to auto-select via the optimized, native
// query-based method
// from the DatasetVersionService:
if (datasetVersionService.getThumbnailByVersionId(versionId) == null) {
if (!hasDatasetLogo && datasetVersionService.getThumbnailByVersionId(versionId) == null) {
return null;
}
}

String url = SystemConfig.getDataverseSiteUrlStatic() + "/api/datasets/" + dataset.getId() + "/logo";
logger.fine("getDatasetCardImageAsUrl: " + url);
this.dvobjectThumbnailsMap.put(datasetId,url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ public static InputStream getLogoAsInputStream(Dataset dataset) {

try {
in = ImageThumbConverter.getImageThumbnailAsInputStream(thumbnailFile.getStorageIO(),
ImageThumbConverter.DEFAULT_CARDIMAGE_SIZE).getInputStream();
ImageThumbConverter.DEFAULT_DATASETLOGO_SIZE).getInputStream();
} catch (IOException ioex) {
logger.warning("getLogo(): Failed to get logo from DataFile for " + dataset.getStorageIdentifier()
+ " (" + ioex.getMessage() + ")");
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/resources/css/structure.css
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ span.search-term-match {font-weight: bold;}
[id$='resultsTable'] div.card-title-icon-block span.label {vertical-align:15%}
[id$='resultsTable'] div.card-preview-icon-block {width:48px; float:left; margin:4px 12px 6px 0;}
[id$='resultsTable'] div.card-preview-icon-block a {display:block; height:48px; line-height:48px;}
[id$='resultsTable'] div.card-preview-icon-block img {vertical-align:middle;}
[id$='resultsTable'] div.card-preview-icon-block img {vertical-align:middle; max-width: 64px; max-height: 48px; padding-right: 10px;}
[id$='resultsTable'] div.card-preview-icon-block span[class^='icon'],
[id$='resultsTable'] div.card-preview-icon-block span[class^='glyphicon'] {font-size:2.8em;}

Expand Down

0 comments on commit 7121498

Please sign in to comment.