choose smallest representation for media preview
authorKatja Luther <k.luther@bgbm.org>
Tue, 7 Nov 2017 12:43:25 +0000 (13:43 +0100)
committerKatja Luther <k.luther@bgbm.org>
Tue, 7 Nov 2017 12:47:58 +0000 (13:47 +0100)
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/MediaViewLabelProvider.java

index 565c6e0b710f1a2ca0175e5de827add28415a8a2..c7dbe1834dbbac7e590e612f3bb0379cb9ac6a20 100755 (executable)
@@ -66,6 +66,19 @@ public class MediaViewLabelProvider extends LabelProvider implements IStyledLabe
             if(representations.iterator().hasNext()){
                 MediaRepresentation rep = representations.iterator().next();
                 List<MediaRepresentationPart> parts = rep.getParts();
+                MediaRepresentationPart smallestPart = null;
+                for (MediaRepresentationPart part: parts){
+                    if (smallestPart != null){
+                        if (smallestPart.getSize() != null && part.getSize() != null) {
+                            if (smallestPart.getSize() > part.getSize()){
+                                smallestPart = part;
+                            }
+                        }
+                    }else{
+                        smallestPart = part;
+                    }
+
+                }
                 URI uri = parts.get(0).getUri();
                 if (uri == null){
                     return null;