Public image from other table?

marcinborzymows
Tera Contributor

Hello,

I have a problem with making image public.

I have   a table (u_configuration) which contains some customizations for portal (images, CSSes etc). One of the fields is an image field (u_header_image).

I made portal page public. It contains only one widget which also is public. I'm trying to use image from u_header_image as a source for <img> tag. That's what I have in Server Script:


var gr = new GlideRecord('u_configuration');
gr.get(some_sys_id);   //Let's assume that some_sys_id is defined somewhere and contains sys_id of desired u_configuration record
data.header_logo = gs.getProperty('glide.servlet.uri') + gr.getDisplayValue('u_header_image');

And that is HTML part:


<div class="logo"><img ng-src="{{::data.header_logo}}" /></div>


Of course it works when I'm logged in but when I try to view site being logged out --> image does not appear, there is standard broken photo icon generated by browser.

Is there any way to do what I'm trying to achieve? It works for Service Portal logo ('logo' field on 'sp_portal' table) but I cannot use it.

2 REPLIES 2

Erik Stolberg
Tera Guru

Are you attaching the file within that field, or attaching the image file to a record? Either way, it's an issue with your read ACLs.



If you are attaching the image, you will need to create a new ACL with "public" as the role and grant "Read" access on the sys_attachment table.



If you are uploading the image to that field, you will need to create a new ACL with "public" as the role and grant "Read" access on your u_configuration.u_header_image table and field.



Is there a specific reason you are unable to use the sp_portal.logo field? Another option to include images would be to attach an image to your sp_portal record or to a CSS record, then copy the link (something like '/sys_attachment.do?sys_id=4ddb31504f863244d59d36651310c70d').


I'm uploading the image to field. Unfortunatelly I cannot give public read to this table as it contains sensitive data. I cannot use sp_portal.logo field because I have a couple of images to show publicly before logging in



I found a workaround - now I'm playing with reading bytes from sys_attachment, encoding them to base64 and displaying in src as a data uri (<img scr="data:image/png;base64,<base64 string>">) but I thought that maybe there is a proper way to do that.



Thank you for idea with attaching images to portal record, I'll try with this.