Images fail at load



  • Hi,

    We are using the jsreport online payment service for our product. We have found a failure when inserting an image in the header. We want to choose the image according to the data we send to the server.

    Our code inside the template header is

    {{#if (getval usrHeader)}}
    <img src="{{getpichdr usrHeader}}" class="header-img" style="width:100px;" />
    {{/if}}
    

    and the template helper functions are,

    function getval(val) {
        return (val) ? true : false;
    }
    function getpichdr(val) {
        return (val) ? '{#image ' + val + '}' : '{#image nopic}';
    }
    

    We have the images loaded in images.

    Should it be done in another way? The images do not appear but we have checked and the 'if' condition is passed correctly. The value of the variable with the name of the image is also correct.

    Thanks


  • administrators

    hi!

    your current code is fine, just have in mind that we recommend to use assets extension instead of image extension, because assets handle more types of content.

    the problem in your report is that in order to show images in the header you must include the image in the main template too, this is due to phantomjs limitations that are documented here, check it for more info and to know how to apply the workaround.

    TL;DR; add this in the content of your main template

    {{#if (getval usrHeader)}}
    <img style="display: none" src="{{getpichdr usrHeader}}" class="header-img" style="width:100px;" />
    {{/if}}
    


  • Ok now, thank you!!


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.