Set image meta data in simple media view
authorPatrick Plitzner <p.plitzner@bgbm.org>
Mon, 7 Dec 2015 17:19:07 +0000 (18:19 +0100)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Mon, 7 Dec 2015 17:19:07 +0000 (18:19 +0100)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/media/MediaDetailElement.java

index 9ae9ade..0f04524 100644 (file)
@@ -17,6 +17,7 @@ import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.Label;
 
 import eu.etaxonomy.cdm.common.media.ImageInfo;
+import eu.etaxonomy.cdm.model.media.ImageFile;
 import eu.etaxonomy.cdm.model.media.Media;
 import eu.etaxonomy.cdm.model.media.MediaRepresentation;
 import eu.etaxonomy.cdm.model.media.MediaRepresentationPart;
@@ -91,15 +92,20 @@ public class MediaDetailElement extends AbstractCdmDetailElement<Media>{
     private void createImageElement(URI uri) {
         ImageInfo imageInfo;
         try {
+            if(uri == null){
+                return;
+            }
             imageInfo = ImageInfo.NewInstance(uri, 10000);
+            singleMediaRepresentationPart.setSize((int) imageInfo.getLength());
+            if(singleMediaRepresentationPart instanceof ImageFile){
+                ((ImageFile) singleMediaRepresentationPart).setHeight(imageInfo.getHeight());
+                ((ImageFile) singleMediaRepresentationPart).setWidth(imageInfo.getWidth());
+            }
             singleMediaRepresentationPart.getMediaRepresentation().setMimeType(imageInfo.getMimeType());
             singleMediaRepresentationPart.getMediaRepresentation().setSuffix(imageInfo.getSuffix());
             element_image = formFactory.createImageElement(parentFormElement, uri, style);
             element_image.initImageUri(uri);
             element_image.loadImage();
-            if(uri == null){
-                return;
-            }
             if(lblNoImage!=null){
                 lblNoImage.dispose();
             }