Copied to clipboard

Flag this post as spam?

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


  • Bo Jacobsen 606 posts 2404 karma points
    Aug 05, 2016 @ 09:06
    Bo Jacobsen
    1

    entityResource getById Media with thumbnail

    Hello everyone.

    The item i get from the dialogService.mediaPicker callback. Contains a thumbnail i can use.

    dialogService.mediaPicker({
            multiPicker: false,
            callback: myCallback,
            startNodeId: node.parentId,
            showDetails: false,
            onlyImages: true
     });
    

    So my question is. Is it possible to get the Media thumbnail from entityResource.getById somehow?

    entityResource.getById(val, "Media").then(function (item) {
        myCallback(item);
    });
    
  • Ronish Potiah 19 posts 171 karma points
    Aug 05, 2016 @ 16:16
    Ronish Potiah
    102

    Hello,

    you can use the "mediaHelper" to get the thumbnail as such:

    entityResource.getById(val, "Media").then(function (item) {
    
    //only show non-trashed items
    if (item.parentId >= -1) {
    
        if (!item.thumbnail) {
            item.thumbnail = mediaHelper.resolveFileFromEntity(item);
        }
    
    });
    

    check the mediaHelper with other methods such as getting the thumbnail here: https://umbraco.github.io/Belle/#/api/umbraco.services.mediaHelper

  • Bo Jacobsen 606 posts 2404 karma points
    Aug 06, 2016 @ 19:35
    Bo Jacobsen
    0

    Thank you!

  • Bilal Haidar 144 posts 410 karma points
    Sep 21, 2016 @ 13:21
    Bilal Haidar
    0

    Hi,

    I injected mediaHelper into my custom directive, but it is always undefined. Anything special to use it?

    angular.module("umbraco.directives")
    .directive('umbMediaPicker', function (dialogService, mediaHelper, entityResource) {
    

    I am trying to get a url for the image selected by the user.

    Thanks

Please Sign in or register to post replies

Write your reply to:

Draft