I know this is an older thread but I have a question in direct context to it so I thought I’d pitch in here - hope that’s OK…
Is there an option to show something if the condition hasn’t been met? I have a db record that may or may not show an image, I’m using a conditional region to show an image if the image name exists in a DB field, however Id like to show a default image if there is no DB field present.
I’m thinking something instead of having: is=“dmx-if” then can we have: is=“dmx-elseif”
heres what I’m using for the dynamic image: <img class="card-img-top rounded img-fluid img-thumbnail" src="" id="card1" width="100px" height="100px" dmx-bind:src="'/images/articles/'+ArticleImageURL.default('/images/apple-icon-72x72.png')" dmx-bind:alt="ArticleAuthor">
This works fine for all records that have image data in the field, however If the ArticleImageURL field is empty I’m getting a missing file in its place…
I’m getting an issue in the version of Wappler (4.9.0) around the default image.
I have the following condition;
‘…/imageuploads/sm_’+image_name.default(‘nopic.png’)
This works correctly in the live preview mode within Wappler but if I view in web browser none of the images show and in the page inspector there is no dynamic data that should be showing the name of my image.
If I used as suggested by Teodor;
dmx-bind:src=“image_name ? ‘…/imageuploads/sm_’+image_name : ‘…/imageuploads/nopic.png’”
Everything works correctly but is not achievable without hand coding which is exactly what I don’t want to have to do in Wappler…
This does not work;
‘…/imageuploads/sm_’+image_name.default(‘nopic.png’) in web browser but works in live preview mode Wappler. The above is generated by Wappler using dynamic attribute > image source > data bindings > data format.
This works but has to be hand coded…
dmx-bind:src=“image_name ? ‘…/imageuploads/sm_’+image_name : ‘…/imageuploads/nopic.png’”
Well the .default formatter is used for different purposes. You can build the working expression logic also using the formatter and the ternary operator.