Copied to clipboard

Flag this post as spam?

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


  • QBank 17 posts 108 karma points
    Mar 11, 2019 @ 08:19
    QBank
    0

    custom property for image media type

    I want to save an image with set of data i.e ( image title, location of image, person who took the photo , ..so on)

    I hope to save these data in image 'porpertycollection ' like follows:

    IMedia newImage =_mediaService.CreateMedia(imageName, parentFolderId, "Image");
    
     newImage.SetValue("imageTitle", TitleOfImage);
    newImage.SetValue("locOfImage", LocationOfImage);
    ......
    _mediaService.Save(newImage)
    

    is above method possible? if so how to create custom PropertyType. else how to store those values related to image.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Mar 11, 2019 @ 09:18
    Dirk De Grave
    1

    Hi Salinda,

    Add new properties on the existing media type "Image" (simple textstring properties will do). As soon as you upload a new image, those new properties will be available. Same as if you'd create the new media using your code.

    Be aware that changing the structure of the existing media type "Image" will impact all images (don't have to supply values for all existing images though).

    Could also create a new media type (copy from the existing one) and add the new properties there (in which case you don't change existing images in media section)

    More info on creating new media types can be found here: https://our.umbraco.com/documentation/Getting-Started/Data/Creating-Media/#creating-a-media-type

    --Dirk

  • QBank 17 posts 108 karma points
    Mar 11, 2019 @ 10:46
    QBank
    0

    Hi Dirk,

    thank you for the idea. but my situation force me to store data related to image in umbraco backend.

    and i have to extend mediaType programmatically

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Mar 11, 2019 @ 11:00
    Dirk De Grave
    0

    See https://our.umbraco.com/documentation/Reference/Management/Services/ContentTypeService/ on how to extend media type programmatically

    --Dirk

Please Sign in or register to post replies

Write your reply to:

Draft