roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r812330 - in /roller/trunk/apps/weblogger: src/java/org/apache/roller/weblogger/business/ src/java/org/apache/roller/weblogger/business/jpa/ src/java/org/apache/roller/weblogger/pojos/ src/java/org/apache/roller/weblogger/ui/rendering/servl...
Date Tue, 08 Sep 2009 02:52:24 GMT
Author: snoopdave
Date: Tue Sep  8 02:52:23 2009
New Revision: 812330

URL: http://svn.apache.org/viewvc?rev=812330&view=rev
Log:
Adds support for true thumbnails. Instead of sending full sized images to the browser and
doing client-side image resizes to create thumbnails, we now store thumbnail images. Also,
we store image width and height as part of image metadata so we can size images correctly.
 

    https://issues.apache.org/jira/browse/ROL-1829


Modified:
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/MediaFileManager.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAMediaFileManagerImpl.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFile.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFile.orm.xml
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/servlets/MediaResourceServlet.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/util/WeblogMediaResourceRequest.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/webservices/atomprotocol/MediaCollection.java
    roller/trunk/apps/weblogger/src/sql/400-to-500-migration.vm
    roller/trunk/apps/weblogger/src/sql/createdb.vm
    roller/trunk/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileAddSuccess.jsp
    roller/trunk/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileView.jsp

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/MediaFileManager.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/MediaFileManager.java?rev=812330&r1=812329&r2=812330&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/MediaFileManager.java
(original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/MediaFileManager.java
Tue Sep  8 02:52:23 2009
@@ -25,7 +25,6 @@
 import org.apache.roller.weblogger.pojos.MediaFile;
 import org.apache.roller.weblogger.pojos.MediaFileDirectory;
 import org.apache.roller.weblogger.pojos.MediaFileFilter;
-import org.apache.roller.weblogger.pojos.ThemeResource;
 import org.apache.roller.weblogger.pojos.Weblog;
 
 /**
@@ -33,6 +32,9 @@
  */
 public interface MediaFileManager {
 
+    public int MAX_WIDTH = 120;
+    public int MAX_HEIGHT = 120;
+
     /**
      * Initialization; deal with upgrade migrations, etc.
      */

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAMediaFileManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAMediaFileManagerImpl.java?rev=812330&r1=812329&r2=812330&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAMediaFileManagerImpl.java
(original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAMediaFileManagerImpl.java
Tue Sep  8 02:52:23 2009
@@ -17,10 +17,16 @@
  */
 package org.apache.roller.weblogger.business.jpa;
 
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.FileReader;
+import java.io.IOException;
 import java.io.InputStream;
 import org.apache.roller.weblogger.business.*;
 import java.sql.Timestamp;
@@ -32,6 +38,7 @@
 import java.util.Properties;
 import java.util.Set;
 import java.util.StringTokenizer;
+import javax.imageio.ImageIO;
 import javax.persistence.NoResultException;
 import javax.persistence.Query;
 
@@ -55,7 +62,7 @@
 public class JPAMediaFileManagerImpl implements MediaFileManager {
 
     private final Weblogger roller;
-    private final JPAPersistenceStrategy persistenceStrategy;
+    private final JPAPersistenceStrategy strategy;
     private static Log log =
         LogFactory.getFactory().getInstance(JPAMediaFileManagerImpl.class);
 
@@ -63,13 +70,15 @@
         MIGRATIION_STATUS_FILENAME = "migration-status.properties";
 
 
+
+
     /**
      * Creates a new instance of MediaFileManagerImpl
      */
     @com.google.inject.Inject
     protected JPAMediaFileManagerImpl(Weblogger roller, JPAPersistenceStrategy persistenceStrategy)
{
         this.roller = roller;
-        this.persistenceStrategy = persistenceStrategy;
+        this.strategy = persistenceStrategy;
     }
 
     /**
@@ -95,7 +104,7 @@
             throws WebloggerException {
         for (MediaFile mediaFile : mediaFiles) {
             mediaFile.setDirectory(targetDirectory);
-            this.persistenceStrategy.store(mediaFile);
+            this.strategy.store(mediaFile);
         }
         // update weblog last modified date.  date updated by saveWebsite()
         roller.getWeblogManager().saveWeblog(targetDirectory.getWeblog());
@@ -132,7 +141,7 @@
      */
     public void createMediaFileDirectory(MediaFileDirectory directory)
             throws WebloggerException {
-        this.persistenceStrategy.store(directory);
+        this.strategy.store(directory);
 
         // update weblog last modified date.  date updated by saveWebsite()
         roller.getWeblogManager().saveWeblog(directory.getWeblog());
@@ -236,11 +245,46 @@
 
         mediaFile.setDateUploaded(new Timestamp(System.currentTimeMillis()));
         mediaFile.setLastUpdated(mediaFile.getDateUploaded());
-        persistenceStrategy.store(mediaFile);
+        strategy.store(mediaFile);
+
         // update weblog last modified date.  date updated by saveWeblog()
         roller.getWeblogManager().saveWeblog(weblog);
 
         cmgr.saveFileContent(weblog, mediaFile.getId(), mediaFile.getInputStream());
+
+        if (mediaFile.isImageFile()) {
+            FileContent fc = cmgr.getFileContent(weblog, mediaFile.getId());
+            BufferedImage img = null;
+            try {
+                img = ImageIO.read(fc.getInputStream());
+
+                // determine and save width and height
+                mediaFile.setWidth(img.getWidth());
+                mediaFile.setHeight(img.getHeight());
+                strategy.store(mediaFile);
+
+                int newWidth = mediaFile.getThumbnailWidth();
+                int newHeight = mediaFile.getThumbnailHeight();
+                
+                // create thumbnail image
+                Image newImage = img.getScaledInstance(
+                        newWidth, newHeight, Image.SCALE_SMOOTH);
+                BufferedImage tmp = new BufferedImage(
+                        newWidth, newHeight, BufferedImage.TYPE_INT_ARGB);
+                Graphics2D g2 = tmp.createGraphics();
+                g2.drawImage(newImage, 0, 0, newWidth, newHeight, null);
+                g2.dispose();
+
+                ByteArrayOutputStream baos = new ByteArrayOutputStream();
+                ImageIO.write(tmp, "png", baos);
+
+                cmgr.saveFileContent(weblog, mediaFile.getId() + "_sm",
+                    new ByteArrayInputStream(baos.toByteArray()));
+
+            } catch (Exception e) {
+                log.debug("ERROR creating thumbnail", e);
+            }
+        }
     }
 
     /**
@@ -248,7 +292,7 @@
      */
     public void updateMediaFile(Weblog weblog, MediaFile mediaFile) throws WebloggerException
{
         mediaFile.setLastUpdated(new Timestamp(System.currentTimeMillis()));
-        persistenceStrategy.store(mediaFile);
+        strategy.store(mediaFile);
         // update weblog last modified date.  date updated by saveWeblog()
         roller.getWeblogManager().saveWeblog(weblog);
     }
@@ -258,7 +302,8 @@
      */
     public void updateMediaFile(Weblog weblog, MediaFile mediaFile, InputStream is) throws
WebloggerException {
         mediaFile.setLastUpdated(new Timestamp(System.currentTimeMillis()));
-        persistenceStrategy.store(mediaFile);
+        strategy.store(mediaFile);
+        
         // update weblog last modified date.  date updated by saveWeblog()
         roller.getWeblogManager().saveWeblog(weblog);
 
@@ -281,11 +326,24 @@
      * {@inheritDoc}
      */
     public MediaFile getMediaFile(String id, boolean includeContent) throws WebloggerException
{
-        MediaFile mediaFile = (MediaFile) this.persistenceStrategy.load(MediaFile.class,
id);
+        MediaFile mediaFile = (MediaFile) this.strategy.load(MediaFile.class, id);
         if (includeContent) {
             FileContentManager cmgr = WebloggerFactory.getWeblogger().getFileContentManager();
+
             FileContent content = cmgr.getFileContent(mediaFile.getDirectory().getWeblog(),
id);
             mediaFile.setContent(content);
+
+            try {
+                FileContent thumbnail = cmgr.getFileContent(mediaFile.getDirectory().getWeblog(),
id + "_sm");
+                mediaFile.setThumbnailContent(thumbnail);
+
+            } catch (Exception e) {
+                if (log.isDebugEnabled()) {
+                    log.debug("Cannot load thumbnail for image " + id, e);
+                } else {
+                    log.warn("Cannot load thumbnail for image " + id);
+                }
+            }
         }
         return mediaFile;
     }
@@ -298,7 +356,7 @@
 
         log.debug("Looking up weblog|path: " + weblog.getHandle() + "|" + path);
 
-        Query q = this.persistenceStrategy.getNamedQuery(
+        Query q = this.strategy.getNamedQuery(
                 "MediaFileDirectory.getByWeblogAndPath");
         q.setParameter(1, weblog);
         q.setParameter(2, path);
@@ -338,7 +396,7 @@
 
         if (!origpath.startsWith("/")) origpath = "/" + origpath;
         
-        Query q = this.persistenceStrategy.getNamedQuery(
+        Query q = this.strategy.getNamedQuery(
                 "MediaFile.getByWeblogAndOrigpath");
         q.setParameter(1, weblog);
         q.setParameter(2, origpath);
@@ -359,7 +417,7 @@
      */
     public MediaFileDirectory getMediaFileDirectory(String id)
             throws WebloggerException {
-        return (MediaFileDirectory) this.persistenceStrategy.load(MediaFileDirectory.class,
id);
+        return (MediaFileDirectory) this.strategy.load(MediaFileDirectory.class, id);
     }
 
     /**
@@ -367,7 +425,7 @@
      */
     public MediaFileDirectory getMediaFileRootDirectory(Weblog weblog)
             throws WebloggerException {
-        Query q = this.persistenceStrategy.getNamedQuery("MediaFileDirectory.getByWeblogAndNoParent");
+        Query q = this.strategy.getNamedQuery("MediaFileDirectory.getByWeblogAndNoParent");
         q.setParameter(1, weblog);
         try {
             return (MediaFileDirectory) q.getSingleResult();
@@ -382,7 +440,7 @@
     public List<MediaFileDirectory> getMediaFileDirectories(Weblog weblog)
             throws WebloggerException {
 
-        Query q = this.persistenceStrategy.getNamedQuery("MediaFileDirectory.getByWeblog");
+        Query q = this.strategy.getNamedQuery("MediaFileDirectory.getByWeblog");
         q.setParameter(1, weblog);
         return q.getResultList();
     }
@@ -394,7 +452,7 @@
             throws WebloggerException {
         FileContentManager cmgr = WebloggerFactory.getWeblogger().getFileContentManager();
 
-        this.persistenceStrategy.remove(mediaFile);
+        this.strategy.remove(mediaFile);
         // update weblog last modified date.  date updated by saveWeblog()
         roller.getWeblogManager().saveWeblog(weblog);
 
@@ -417,7 +475,7 @@
 
         queryString.append("SELECT m FROM MediaFile m WHERE m.sharedForGallery = true");
         queryString.append(" order by m.dateUploaded");
-        Query query = persistenceStrategy.getDynamicQuery(queryString.toString());
+        Query query = strategy.getDynamicQuery(queryString.toString());
         query.setFirstResult(0);
         query.setMaxResults(length);
         return query.getResultList();
@@ -515,7 +573,7 @@
             }
         }
 
-        Query query = persistenceStrategy.getDynamicQuery(queryString.toString() + whereClause.toString()
+ orderBy.toString());
+        Query query = strategy.getDynamicQuery(queryString.toString() + whereClause.toString()
+ orderBy.toString());
         for (int i = 0; i < params.size(); i++) {
             query.setParameter(i + 1, params.get(i));
         }
@@ -729,6 +787,6 @@
         for (MediaFileDirectory md : dirs) {
             removeMediaFileDirectory(md);
         }
-        this.persistenceStrategy.remove(dir);
+        this.strategy.remove(dir);
     }
 }

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFile.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFile.java?rev=812330&r1=812329&r2=812330&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFile.java
(original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFile.java
Tue Sep  8 02:52:23 2009
@@ -24,6 +24,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.util.UUIDGenerator;
+import org.apache.roller.weblogger.business.MediaFileManager;
 import org.apache.roller.weblogger.business.WebloggerFactory;
 
 /**
@@ -41,17 +42,25 @@
     private String      description;
     private String      copyrightText;
     private Boolean     isSharedForGallery;
-    long                length;
+    private long        length;
+    private int         width = -1;
+    private int         height = -1;
+    private int         thumbnailHeight = -1;
+    private int         thumbnailWidth = -1;
     private String      contentType;
     private String      originalPath;
-    private InputStream is;
-    private FileContent content;
     private Timestamp   dateUploaded;
     private Timestamp   lastUpdated;
     private String      creatorUserName;
+    private Weblog      weblog;
+
+    private InputStream is;
+
     private MediaFileDirectory directory;
     private Set<MediaFileTag>  tags;
-    private Weblog      weblog;
+
+    private FileContent content;
+    private FileContent thumbnail;
 
     
     // TODO: anchor to be populated
@@ -283,4 +292,88 @@
     public void setWeblog(Weblog weblog) {
         this.weblog = weblog;
     }
+
+    /**
+     * @return the width
+     */
+    public int getWidth() {
+        return width;
+    }
+
+    /**
+     * @param width the width to set
+     */
+    public void setWidth(int width) {
+        this.width = width;
+    }
+
+    /**
+     * @return the height
+     */
+    public int getHeight() {
+        return height;
+    }
+
+    /**
+     * @param height the height to set
+     */
+    public void setHeight(int height) {
+        this.height = height;
+    }
+
+    /**
+     * Returns input stream for the underlying thumbnail file in the file system.
+     * @return
+     */
+    public InputStream getThumbnailInputStream() {
+        if (thumbnail != null) {
+            return thumbnail.getInputStream();
+        }
+        return null;
+    }
+
+    public void setThumbnailContent(FileContent thumbnail) {
+        this.thumbnail = thumbnail;
+    }
+
+    /**
+     * @return the thumbnailHeight
+     */
+    public int getThumbnailHeight() {
+        if (isImageFile() && (thumbnailWidth == -1 || thumbnailHeight == -1)) {
+            figureThumbnailSize();
+        }
+        return thumbnailHeight;
+    }
+
+    /**
+     * @return the thumbnailWidth
+     */
+    public int getThumbnailWidth() {
+        if (isImageFile() && (thumbnailWidth == -1 || thumbnailHeight == -1)) {
+            figureThumbnailSize();
+        }
+        return thumbnailWidth;
+    }
+
+    private void figureThumbnailSize() {
+        // image determine thumbnail size
+        int newWidth = getWidth();
+        int newHeight = getHeight();
+
+        if (getWidth() > getHeight()) {
+            if (getWidth() > MediaFileManager.MAX_WIDTH) {
+                newHeight = (int)((float)getHeight() * ((float)MediaFileManager.MAX_WIDTH
/ (float)getWidth()));
+                newWidth = MediaFileManager.MAX_WIDTH;
+            }
+
+        } else {
+            if (getHeight() > MediaFileManager.MAX_HEIGHT) {
+                newWidth = (int)((float)getWidth() * ((float)MediaFileManager.MAX_HEIGHT
/ (float)getHeight()));
+                newHeight = MediaFileManager.MAX_HEIGHT;
+            }
+        }
+        thumbnailHeight = newHeight;
+        thumbnailWidth = newWidth;
+    }
 }

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFile.orm.xml
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFile.orm.xml?rev=812330&r1=812329&r2=812330&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFile.orm.xml
(original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFile.orm.xml
Tue Sep  8 02:52:23 2009
@@ -22,6 +22,12 @@
             <basic name="name">
                 <column name="name" insertable="true" updatable="true" unique="false"
nullable="false"/>
             </basic>
+            <basic name="width">
+                <column name="width" insertable="true" updatable="true" unique="false"
nullable="true"/>
+            </basic>
+            <basic name="height">
+                <column name="height" insertable="true" updatable="true" unique="false"
nullable="true"/>
+            </basic>
             <basic name="originalPath">
                 <column name="origpath" insertable="true" updatable="false" unique="false"
nullable="true"/>
             </basic>
@@ -60,6 +66,8 @@
                     <cascade-all />
                 </cascade>
             </one-to-many>
+            <transient name="thumbnailHeight"/>
+            <transient name="thumbnailWidth"/>
         </attributes>
     </entity>
 </entity-mappings>

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/servlets/MediaResourceServlet.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/servlets/MediaResourceServlet.java?rev=812330&r1=812329&r2=812330&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/servlets/MediaResourceServlet.java
(original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/servlets/MediaResourceServlet.java
Tue Sep  8 02:52:23 2009
@@ -116,9 +116,24 @@
         
 
         // set the content type based on whatever is in our web.xml mime defs
-        response.setContentType(mediaFile.getContentType());
-        resourceStream = mediaFile.getInputStream();
-        
+        if (resourceRequest.isThumbnail()) {
+            response.setContentType("image/png");
+            try {
+                resourceStream = mediaFile.getThumbnailInputStream();
+            } catch (Exception e) {
+                if (log.isDebugEnabled()) {
+                    log.debug("ERROR loading thumbnail for " + mediaFile.getId(), e);
+                } else {
+                    log.warn("ERROR loading thumbnail for " + mediaFile.getId());
+                }
+            }
+        }
+
+        if (resourceStream == null) {
+            response.setContentType(mediaFile.getContentType());
+            resourceStream = mediaFile.getInputStream();
+        }
+
         OutputStream out = null;
         try {
             // ok, lets serve up the file
@@ -132,7 +147,8 @@
             // close output stream
             out.close();
             
-        } catch (Exception ex) {
+        } catch (Throwable ex) {
+            log.error("ERROR",ex);
             if(!response.isCommitted()) {
                 response.reset();
                 response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/util/WeblogMediaResourceRequest.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/util/WeblogMediaResourceRequest.java?rev=812330&r1=812329&r2=812330&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/util/WeblogMediaResourceRequest.java
(original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/util/WeblogMediaResourceRequest.java
Tue Sep  8 02:52:23 2009
@@ -34,6 +34,8 @@
         
     // lightweight attributes
     private String resourceId = null;
+
+    private boolean thumbnail = false;
     
     
     public WeblogMediaResourceRequest() {}
@@ -72,6 +74,10 @@
             throw new InvalidRequestException("invalid resource path info, "+
                     request.getRequestURL());
         }
+
+        if (request.getParameter("t") != null && "true".equals(request.getParameter("t")))
{
+            thumbnail = true;
+        }
         
         if(log.isDebugEnabled()) {
             log.debug("resourceId = "+this.resourceId);
@@ -91,4 +97,18 @@
         // keep parent from treating upload sub-directory name as a locale.
         return false;
     }
+
+    /**
+     * @return the thumbnail
+     */
+    public boolean isThumbnail() {
+        return thumbnail;
+    }
+
+    /**
+     * @param thumbnail the thumbnail to set
+     */
+    public void setThumbnail(boolean thumbnail) {
+        this.thumbnail = thumbnail;
+    }
 }

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/webservices/atomprotocol/MediaCollection.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/webservices/atomprotocol/MediaCollection.java?rev=812330&r1=812329&r2=812330&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/webservices/atomprotocol/MediaCollection.java
(original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/webservices/atomprotocol/MediaCollection.java
Tue Sep  8 02:52:23 2009
@@ -58,7 +58,6 @@
 import org.apache.roller.weblogger.config.WebloggerRuntimeConfig;
 import org.apache.roller.weblogger.pojos.MediaFile;
 import org.apache.roller.weblogger.pojos.MediaFileDirectory;
-import org.apache.roller.weblogger.pojos.ThemeResource;
 import org.apache.roller.weblogger.pojos.User;
 import org.apache.roller.weblogger.pojos.Weblog;
 import org.apache.roller.weblogger.util.Utilities;

Modified: roller/trunk/apps/weblogger/src/sql/400-to-500-migration.vm
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/sql/400-to-500-migration.vm?rev=812330&r1=812329&r2=812330&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/sql/400-to-500-migration.vm (original)
+++ roller/trunk/apps/weblogger/src/sql/400-to-500-migration.vm Tue Sep  8 02:52:23 2009
@@ -111,6 +111,8 @@
     directoryid     varchar(48) not null,
     weblogid        varchar(48) not null,
     size_in_bytes   integer,
+    width           integer,
+    height          integer,
     date_uploaded   $db.TIMESTAMP_SQL_TYPE not null,
     last_updated    $db.TIMESTAMP_SQL_TYPE,
     anchor          varchar(255),

Modified: roller/trunk/apps/weblogger/src/sql/createdb.vm
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/sql/createdb.vm?rev=812330&r1=812329&r2=812330&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/sql/createdb.vm (original)
+++ roller/trunk/apps/weblogger/src/sql/createdb.vm Tue Sep  8 02:52:23 2009
@@ -540,6 +540,8 @@
     copyright_text  varchar(1023),
     directoryid     varchar(48) not null,
     weblogid        varchar(48) not null,
+    width           integer,
+    height          integer,
     size_in_bytes   integer,
     date_uploaded   $db.TIMESTAMP_SQL_TYPE not null,
     last_updated    $db.TIMESTAMP_SQL_TYPE,

Modified: roller/trunk/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileAddSuccess.jsp
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileAddSuccess.jsp?rev=812330&r1=812329&r2=812330&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileAddSuccess.jsp (original)
+++ roller/trunk/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileAddSuccess.jsp Tue Sep  8
02:52:23 2009
@@ -30,7 +30,7 @@
 </ul>
 </div>
 
-<s:url id="mediaFileURL" value="/roller-ui/rendering/media-resources/%{bean.id}">
+<s:url id="mediaFileURL" value="/%{actionWeblog.handle}/mediaresource/%{bean.id}">
 </s:url>
 
 <s:if test="contentTypeImage">

Modified: roller/trunk/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileView.jsp
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileView.jsp?rev=812330&r1=812329&r2=812330&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileView.jsp (original)
+++ roller/trunk/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileView.jsp Tue Sep  8 02:52:23
2009
@@ -305,15 +305,23 @@
 
             <li class="align-images" onmouseover="" onmouseout="">
 
-                <s:if test="#mediaFile.imageFile">
-                    <s:url id="mediaFileURL" value="/%{#mediaFile.weblog.handle}/mediaresource/%{#mediaFile.id}"></s:url>
-                </s:if>
-                <s:else>
-                    <s:url id="mediaFileURL" value="/images/page.png"></s:url>
-                </s:else>
                 <div style="border:1px solid #000000;width:120px;height:100px;margin:5px;">
-                    <img border="0" src='<s:property value="%{mediaFileURL}" />'
<s:if test="#mediaFile.imageFile"> width="120px" height="100px" </s:if> <s:else>style="padding:40px
50px;"</s:else>/>
+                    <s:if test="#mediaFile.imageFile">
+                        <s:url id="mediaFileURL"
+                            value="/%{#mediaFile.weblog.handle}/mediaresource/%{#mediaFile.id}?t=true"></s:url>
+
+                        <img border="0" src='<s:property value="%{mediaFileURL}" />'
+                             width='<s:property value="#mediaFile.thumbnailWidth"/>'
+                             height='<s:property value="#mediaFile.thumbnailHeight"/>'
+                    </s:if>
+
+                    <s:else>
+                        <s:url id="mediaFileURL" value="/images/page.png"></s:url>
+                        <img border="0" src='<s:property value="%{mediaFileURL}" />'
+                             style="padding:40px 50px;" />
+                    </s:else>
                 </div>
+
                 <div style="clear:left;width:130px;margin-left:5px;font-size:11px;">
 
                     <label>



Mime
View raw message