Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • WestLifeUmbraco 39 posts 70 karma points
    Jun 20, 2013 @ 02:55
    WestLifeUmbraco
    0

    Image thumbnail auto-generation for existing images

    I want to auto-generate image thumbnail for all images in Meda tab. I set a width value (e.g. 200) for the Upload data type. However, this only applies to image added after the new setting. Existing images that were added before the new value don't have thumbnail with the specified width.

    How can I generate the image thumbnails with the specified with for all the exsting images.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jun 20, 2013 @ 20:08
    Jan Skovgaard
    0

    Hi Pingpong

    What version of Umbraco are you using? If I remember correctly one is not able to alter the value of the preview width in newer versions of Umbraco? But I do remember that it was possible in older versions when the more advanced media picker was a 3rd party package.

    Looking forward to hearing from you.

    Cheers,
    Jan 

  • Rich Green 2246 posts 4008 karma points
    Jun 21, 2013 @ 10:40
    Rich Green
    0

    Hey,

    Not sure it's possible without coding as these thumbnails are created when you upload or save the image.

    Why don't you just use imagegen to create the thumbnails on the fly like

    /imagegen.ashx?image=/media/image.jpg&width=200

    Rich

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Jun 21, 2013 @ 13:40
    Jeroen Breuer
    0

    Hello,

    Is the thumbnail generated after the media item is resaved? You could write some custom code which resaved all the images. Something like this (with the old API):

    public class MediaExample
    {
        protected static umbraco.DataLayer.ISqlHelper SqlHelper
        {
            get { return umbraco.BusinessLogic.Application.SqlHelper; }
        }
    
        public static void SaveMedia()
        {
            string sql = @"
            select un.id
            from umbracoNode un
            where un.nodeObjectType = @type";
    
            //Get all the media items.
            using (IRecordsReader dr = SqlHelper.ExecuteReader(sql, SqlHelper.CreateParameter("@type", Media._objectType)))
            {
                //Loop trough all the media items.
                while (dr.Read())
                {
                    //Get the id of a media item.
                    int mediaId = dr.GetInt("id");
    
                    //Call the save method so all save events can be fired again.
                    Media media = new Media(mediaId);
                    media.Save();
                    media.XmlGenerate(new XmlDocument());
                }
            }
        }
    }

    Just call MediaExample.SaveMedia(); somewhere to resave all media.

    Jeroen

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Jun 21, 2013 @ 13:41
    Jeroen Breuer
    0

    And if you only need cropped thumbnails you could have a look at the DAMP Gallery: http://24days.in/umbraco/2012/damp-gallery/

    Jeroen

Please Sign in or register to post replies

Write your reply to:

Draft