Copied to clipboard

Flag this post as spam?

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


  • Bishal Tim 26 posts 135 karma points c-trib
    Jun 13, 2024 @ 09:26
    Bishal Tim
    0

    media retrieval in umbraco v14

    I'm currently in the process of migrating an AngularJS package to v14. One of the key changes involves media retrieval functionality. In Umbraco v12, I had the following code:

    if (item.Media) {
        mediaResource.getById(item.Media).then(function (media) {
            item.Media = media.mediaLink;
        });
    } else {
        item.Media = getDefaultImage(item);
    }
    

    Now, in Umbraco v14, I've updated the code as follows:

    for (let item of items) {
        if (item.Media) {
            const mediaUrl = await MediaService.getMediaUrls(item.Media);
            console.log(" item media:", mediaUrl);
            item.Media = mediaUrl;
        } else {
            item.Media = this.getDefaultImage(item);
        }
    }
    

    I would appreciate any insights or guidance on

    Correct approach for media retrieval in Umbraco v14.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies