You are viewing limited content. For full access, please sign in.

Question

Question

Replacement image for missing images/images not shown Laserfiche forms

asked on August 7 Show version history

On LF Forms 11 Update 5, using modern designer/ Forms Layout designer,  I've create a printable report that uses dynamic images within a custom html field sourced from a url provided by a database table.  Occasionally, there is a url in the table value, but there is no image available on the server that hosts the images, and my users would like a default visually friendly image inserted instead. 

I've unsuccessfully tried to replace the missing image using the onerror attribute inside the img tag solution and using an object/img solution.  Both are not supported in this set up.

Is there any way to set a default image for the missing images?

0 0

Replies

replied on August 7

"sourced from a url provided by a database table.  Occasionally, the url doesn't exist "

Do you mean that the table value is non-existent?  Or, do you mean that the url references something that does not exist?

0 0
replied on August 7

Sorry, I could have been more clear there. There is a url in the table value, but there is no image available on the server that hosts the images.  For instance, they may add a new sign type to the database and not have completed the task of adding the new sign image to the server.

0 0
replied on August 7

How is the URL value populated?  Is it a simple lookup in forms?

0 0
replied on August 7 Show version history

Not having done it... I would suggest referencing 

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/img

It looks like you can create an "onerror" handler for the <img> element that will then change the source attribute and then trigger a change event for the <img> element to display it with a default icon.

Good luck.

0 0
replied on August 7

The image is named the same as the sign type identifier, and the url is contructed leveraging that structure.  The html content is updated using javascript LFForm.changeFieldSettings.  The Onerror solution produces this message in the console: 

I appreciate the review.

0 0
replied two days ago

Can you share the code that you've tried using "onerror"? It should be calling a JavaScript function to change the src to your default image.

0 0
replied two days ago
<div class="RLsign" style="text-align:center; max-height:75px; max-width:75px;"><img src="{/dataset/Road_Log/MUTCD_url}" onerror="this.onerror=null; this.src=&quot;https://EnterImageURL.jpg&quot;;" style="max-
height:75px; max-width:75px; vertical-align: middle;"></div>

I tinkered with a couple styles of quoting but it didn't seem to matter.  It renders in the Custom HTML preview but gives me the above message when previewing or starting the form.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.