Skip to content
Franco Mussopower pages
Code snippet

Check whether Image column contains data before retrieving

Copy it with the button on the code. For the why and the walkthrough, see “How to retrieve Image columns using Power Pages’ Portal Web API”.

Check whether Image column contains data before retrievingLiquid
{% assign track_record = entities['musdyn_track'][request.params.id] %}
{% if track_record.musdyn_artworkid %}
    <script>
        webapi.safeAjax({
            type: "GET",
            url: "/_api/musdyn_tracks({{ request.params.id }})/musdyn_artwork/?size=full",
            contentType:"application/json",
            success: function(res) {
                $('#main').append('<img class="img-responsive" src="data:image/png;base64,' + res.value + '">');
            },
            error: function(xhr, status, error){
                $('#main').append('<img class="img-responsive" src="/artwork-not-found.svg">');
                var errorMessage = xhr.status + ': ' + xhr.statusText;
                console.log(errorMessage);
            }
        });
    </script>
{% endif %}

Search

Book a discovery call

30 minutes. Bring your trickiest Power Pages problem — I’ll tell you honestly whether I’m the right fit.