Copied to clipboard

Flag this post as spam?

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


  • P 32 posts 122 karma points
    Feb 09, 2016 @ 10:09
    P
    0

    imageHelper deprecated? what to use instead?

  • Tom Steer 161 posts 596 karma points
    Feb 09, 2016 @ 10:14
    Tom Steer
    0

    Hi Pete,

    Looks like mediaHelper replaces it, based on this commit:

    https://github.com/umbraco/Umbraco-CMS/commit/bf5bb8bc7028939919e3394a7cd111957b83a39a

    Thanks,

    Tom

  • P 32 posts 122 karma points
    Feb 09, 2016 @ 10:42
    P
    0

    Thanks Tom.

    Given that every call in imageHelper is a simple wrapper around mediaHelper, I feel pretty daft for missing that. :)

    Now I just need to figure out how to use a media item id to get the url or the image. I'm using the following:

                dialogService.mediaPicker({
                callback: function (data) {
                    var id = data.id;
                    mediaResource.getById(id)
                        .then(function (item) {
                            var media = mediaHelper.resolveFile({ mediaItem: item, scope: $scope });
                            alert(JSON.stringify(media));
                        });                                        
                }
            });
    

    But media is always an empty string.

    Cheers

    Pete

  • P 32 posts 122 karma points
    Feb 09, 2016 @ 11:29
    P
    0

    Got it. Looks like you don't need to resolve the file yourself. The following works for me.

            dialogService.mediaPicker({
                callback: function (data) {
                    var id = data.id;
                    mediaResource.getById(id)
                        .then(function (item) {                            
                            var media = mediaHelper.getImagePropertyValue({ mediaModel: item, scope: $scope });
                            // do thing with media
                        });                                        
                }
            });
    
Please Sign in or register to post replies

Write your reply to:

Draft