Copied to clipboard

Flag this post as spam?

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


  • mcgrph 35 posts 162 karma points
    Jun 24, 2019 @ 21:44
    mcgrph
    1

    entityResource returns null for umbracoWidth and -Height

    I'm currently trying to setup a custom section and inside I added a mediaPicker which is working fine. Unfortunately the thumbnail is not shown properly, because somehow the values for umbracoWidth and umbracoHeight I get back are always null.

    When I load the page, I call this specific function:

    entityResource.getById(id, "Media").then(entity => {
        vm.model.image.thumbnail    = entity.metaData.umbracoFile.Value.src;
        vm.model.image.width        = entity.metaData.umbracoWidth.Value;
        vm.model.image.height       = entity.metaData.umbracoHeight.Value;  });
    

    The entity is returned correctly in the promise, except that width and height are always null:

    Screenshot of developer console after catching the promise

    This causes the umbraco thumbnail to fail:

    <umb-image-thumbnail width="{{ vm.model.image.width }}"
                     height="{{ vm.model.image.height }}"
                     src="vm.model.image.thumbnail"
                     max-size="100" />
    

    Has someone an idea on what I'm missing out here?

  • Tarik | WPPlumber 179 posts 801 karma points c-trib
    Jun 25, 2019 @ 12:13
    Tarik | WPPlumber
    101

    I suggest to use mediaResource.

            mediaResource.getById(your_id)
            .then(function(media) {
                var myMedia = media; 
            // Display image Height 
                console.log( 'Image height :  ' + myMedia.tabs[0].properties[2].value);
            });
    
  • mcgrph 35 posts 162 karma points
    Jun 25, 2019 @ 21:13
    mcgrph
    0

    Thanks Tarik, that was indeed the solution!

Please Sign in or register to post replies

Write your reply to:

Draft