How can I display and print photos in a report

  • 1
  • 2
  • Question
  • Updated 1 year ago
  • Answered
I am using the asset tracking template to keep track of furniture. I have added a field for images to upload a picture of the furniture. I need to print out a list of furniture with an image. Is this possible?
Photo of Nate

Nate

  • 80 Points 75 badge 2x thumb

Posted 1 year ago

  • 1
  • 2
Photo of Paul

Paul

  • 42 Points
yup!

with some code courtesy of Chris - (see his original here )


[image] is your attachment field
[name] is the title of your item ( chair, sofa, etc)

i put it in a <div> that's 150px wide with a white background, so it always prints nice, 
then put the NAME on the left and the IMAGE on the right, 50px tall.


 "<div style=\"background-color:#FFF; width:150px; height:52px; \">  " 
&
"<div style=\"float:left; width:60px; color:#636363; font-size:14px; font-family:Arial; \">" & [Name] & "</div>"
&
" <div style=\"float:right;\"><img style=\" height:50px;\" src=\"" &  URLRoot() & "up/" & Dbid() & "/a/r" & [Record ID#] & "/e6/v0/" & [image]  & "\" ></div> " 
&
"</div>


if you just want the image on the report, and they're all the right size, etc, then you just need the brilliant code from Chris to transform the image into a web url...

URLRoot() & "up/" & Dbid() & "/a/r" & [Record ID#] & "/e6/v0/" & [Image]

(Edited)
Photo of Arshad Khwaja

Arshad Khwaja

  • 3,132 Points 3k badge 2x thumb
Is there a way I can re size a photo in a form so that it is not too big? 
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,306 Points 50k badge 2x thumb
Try this format for a formula text field with html enabled and where the actual file attachment has been uploaded to field ID 282.,


var text FileType = Right(ToText([file attachment2]),".");

If(Contains("jpg, jepg, png",$FileType),
"<img src=" & URLRoot() & "up/" & Dbid() & "/a/r" & [Record ID#] & "/e282/v0' width='75' >")

You can adjust the width to different values until you get the size you like.

Alternatively you can use this to control the height.  The only difference is that we are specifying the height and not the width.  (you can also specify both, but then the image may get skewed in either the height or the width.

var text FileType = Right(ToText([file attachment2]),".");

If(Contains("jpg, jepg, png",$FileType),
"<img src=" & URLRoot() & "up/" & Dbid() & "/a/r" & [Record ID#] & "/e282/v0' height='75' >")


The purpose of the IF is to display nothing if there is not file attachment or if the file attachment is not an image.  For example, this will not work for an Excel, PDF, or Word attachment.
Photo of Arshad Khwaja

Arshad Khwaja

  • 3,132 Points 3k badge 2x thumb
This is a great response Mark. Thanks. 
Photo of Arshad Khwaja

Arshad Khwaja

  • 3,132 Points 3k badge 2x thumb
I also picked up the following statement  which I added to a formula text and it worked. But I like the idea of testing for an attachment. Is the file attachment 2 in Var  is the name of the field? 
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,306 Points 50k badge 2x thumb
yes, the name of the field in my example was [file attachment 2]
Photo of Arshad Khwaja

Arshad Khwaja

  • 3,132 Points 3k badge 2x thumb
Thanks a lot. Works great.