Copied to clipboard

Flag this post as spam?

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


  • kososki 8 posts 28 karma points
    May 14, 2014 @ 13:22
    kososki
    0

    [v7] Custom Media Picker - problem with image properties and thumbnail

    Hi everyone,
    I'm creating my own custom media picker and I have problem with few things.
    In Code I'm creating IMedia object and I'm setting properties like that :


    media.SetValue("umbracoWidth", element.Width);
    media.SetValue("umbracoHeight", element.Height);
    media.SetValue("umbracoBytes", element.FileSize);
    media.Properties["umbracoExtension"].Value = element.Extension;
    media.Properties["umbracoFile"].Value = "plugins/media/"

     

    The problem is that properties Width, Height and FileSize after saving using MediaService are -1 in database. The second problem is that I'm saving the image file to the disk using Bitmap.Save with the location set in "umbracoFile" property, also I'm creating thumbnail image in the same folder.

    Unfortunately when I refresh the media folder in backend new media item exists but these three properties are -1 and Umbraco doesn't see my thumbnail (I'm generating file with the same name with _thumb" in the same location.

     

    Can anyone tell me what else should I set in code behind that Umbraco would treat my image the same way as uploaded via default image picker ?

    And the next question - where is stored the information about relation between logical media folder id and the physical folder on the disk ?

    E.x. I'm uploading image to media folder with id 1050 and it's stored on HDD in folder "/media/1005/image.jpg". Where is stored the information that logical 1050 is related with physical 1005 ?

     

    Regards
    Tomasz

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    May 15, 2014 @ 09:48
    Jeavon Leopold
    0

    Hi Tomasz,

    Welcome to Our!

    Are you using the MediaService to Save your new object? Perhaps you could post a bit more of your code?

    Jeavon

  • kososki 8 posts 28 karma points
    May 15, 2014 @ 09:58
    kososki
    0

    Yes, I'm using MediaService to create object IMedia

    IMedia media = mediaService.CreateMedia(element.FileName, parent, "Image");

    And then

    mediaService.Save(media);

    When the item is saved (id will be assigned) I complete specified above properties and save it again, but only path and extension are correct in database.

    But this is only one, let's say, smaller problem. The second is that Umbraco doesn't see my thumbnail which is in the same folder as the original image but with "_thumb". How can I make Umbraco will see my files

     

    In database it looks like this (the only difference to the image uploaded via default uploader are these -1 :

     <Image id="1170" key="23eafeb6-1ca3-4cf7-aa29-31310e68393e" parentID="1137" level="4" creatorID="0" sortOrder="8" createDate="2014-05-14T11:39:17" updateDate="2014-05-14T11:39:27" nodeName="auto.png (1)" urlName="autopng-1" path="-1,1046,1133,1137,1170" isDoc="" nodeType="1032" writerName="user" writerID="0" version="9560dfe0-4bfb-46e1-8b32-7e99aa8f3301" template="0" nodeTypeAlias="Image">
       <umbracoFile><![CDATA[plugins/media/1137/auto.png]]></umbracoFile>
       <umbracoWidth><![CDATA[-1]]></umbracoWidth>
       <umbracoHeight><![CDATA[-1]]></umbracoHeight>
       <umbracoBytes><![CDATA[-1]]></umbracoBytes>
       <umbracoExtension><![CDATA[png]]></umbracoExtension>
     </Image>

    Tomasz

Please Sign in or register to post replies

Write your reply to:

Draft