Display single upload image

6 posts by 3 authors in: Forums > CMS Builder
Last Post: April 26, 2010   (RSS)

By kkegans - April 26, 2010

I am using upload to allow the client to add a company logo to a page in a single record editor. The upload is limited to one image being upploaded.

What is the proper way to display the upload image, when there is no need for the ForEach, If, ElseIf, Else?.
CMSB Rocks!
Thanks,
Kurt

Re: [kkegans] Display single upload image

By Jason - April 26, 2010

Hi,

Even if there is only 1 image uploaded, the code generated by the code generator will still work, even with the If's and ForEach.

Are you running into a specific problem? If so, maybe you can attach the .php file you're working with and a description of the problem, then I can take a look at it for you.

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Display single upload image

By kkegans - April 26, 2010

Thanks Jason, I just thought there might be a little cleaner and less bloated way of coding to achieve the desired result.
CMSB Rocks!
Thanks,
Kurt

Re: [kkegans] Display single upload image

By Jason - April 26, 2010

Hi,

If you want to post the code you're currently using, I can take a look at cleaning it up a bit for you if you want.

Let me know.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [kkegans] Display single upload image

By Perchpole - April 26, 2010

Hi, KKegans

If you know for sure that you will have an image for every record, and you intend to display the full image - not the thumbnail - you only need this code...

<?php foreach ($yourRecord['image'] as $upload): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" />
<?php endforeach ?>


Give it a try.

:0)

Perchpole