Skip to content

Commit 7121498

Browse files
committed
Fix thumbnail issues
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.
1 parent 4d9a25b commit 7121498

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

src/main/java/edu/harvard/iq/dataverse/DatasetServiceBean.java

+1
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,7 @@ public Dataset setNonDatasetFileAsThumbnail(Dataset dataset, InputStream inputSt
849849
}
850850
dataset = DatasetUtil.persistDatasetLogoToStorageAndCreateThumbnails(dataset, inputStream);
851851
dataset.setThumbnailFile(null);
852+
dataset.setUseGenericThumbnail(false);
852853
return merge(dataset);
853854
}
854855

src/main/java/edu/harvard/iq/dataverse/ThumbnailServiceWrapper.java

+19-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
import java.util.HashMap;
1414
import java.util.Map;
1515
import java.util.logging.Logger;
16+
import edu.harvard.iq.dataverse.dataaccess.DataAccess;
17+
import edu.harvard.iq.dataverse.dataaccess.StorageIO;
18+
import edu.harvard.iq.dataverse.dataset.DatasetUtil;
19+
import java.io.IOException;
1620

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

171175
if (thumbnailFile == null) {
172176

173-
// We attempt to auto-select via the optimized, native query-based method
177+
boolean hasDatasetLogo = false;
178+
StorageIO<DvObject> storageIO = null;
179+
try {
180+
storageIO = DataAccess.getStorageIO(dataset);
181+
if (storageIO.isAuxObjectCached(DatasetUtil.datasetLogoFilenameFinal)) {
182+
// If not, return null/use the default, otherwise pass the logo URL
183+
hasDatasetLogo = true;
184+
}
185+
} catch (IOException ioex) {
186+
logger.warning("getDatasetCardImageAsUrl(): Failed to initialize dataset StorageIO for "
187+
+ dataset.getStorageIdentifier() + " (" + ioex.getMessage() + ")");
188+
}
189+
// If no other logo we attempt to auto-select via the optimized, native
190+
// query-based method
174191
// from the DatasetVersionService:
175-
if (datasetVersionService.getThumbnailByVersionId(versionId) == null) {
192+
if (!hasDatasetLogo && datasetVersionService.getThumbnailByVersionId(versionId) == null) {
176193
return null;
177194
}
178195
}
179-
180196
String url = SystemConfig.getDataverseSiteUrlStatic() + "/api/datasets/" + dataset.getId() + "/logo";
181197
logger.fine("getDatasetCardImageAsUrl: " + url);
182198
this.dvobjectThumbnailsMap.put(datasetId,url);

src/main/java/edu/harvard/iq/dataverse/dataset/DatasetUtil.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ public static InputStream getLogoAsInputStream(Dataset dataset) {
464464

465465
try {
466466
in = ImageThumbConverter.getImageThumbnailAsInputStream(thumbnailFile.getStorageIO(),
467-
ImageThumbConverter.DEFAULT_CARDIMAGE_SIZE).getInputStream();
467+
ImageThumbConverter.DEFAULT_DATASETLOGO_SIZE).getInputStream();
468468
} catch (IOException ioex) {
469469
logger.warning("getLogo(): Failed to get logo from DataFile for " + dataset.getStorageIdentifier()
470470
+ " (" + ioex.getMessage() + ")");

src/main/webapp/resources/css/structure.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ span.search-term-match {font-weight: bold;}
484484
[id$='resultsTable'] div.card-title-icon-block span.label {vertical-align:15%}
485485
[id$='resultsTable'] div.card-preview-icon-block {width:48px; float:left; margin:4px 12px 6px 0;}
486486
[id$='resultsTable'] div.card-preview-icon-block a {display:block; height:48px; line-height:48px;}
487-
[id$='resultsTable'] div.card-preview-icon-block img {vertical-align:middle;}
487+
[id$='resultsTable'] div.card-preview-icon-block img {vertical-align:middle; max-width: 64px; max-height: 48px; padding-right: 10px;}
488488
[id$='resultsTable'] div.card-preview-icon-block span[class^='icon'],
489489
[id$='resultsTable'] div.card-preview-icon-block span[class^='glyphicon'] {font-size:2.8em;}
490490

0 commit comments

Comments
 (0)