Print Image Title

10 posts by 4 authors in: Forums > CMS Builder
Last Post: March 3, 2009   (RSS)

Hi, Is there a way to display the image title and caption beside or beneath an uploaded image?

Re: [Dan Maitland] Print Image Title

By Kenny - February 22, 2009 - edited: February 22, 2009

Dan,

Use echo statements to do this like any other data. For example:

<?php echo $upload['info1'] ?> will display what ever you have that textfield set to. In this case, you probably have info1 set to "Title"

<?php echo $upload['info2'] ?> will display your second textfield


Make sense?


Kenny

Re: [sagentic] Print Image Title

By gkornbluth - February 22, 2009 - edited: February 22, 2009

Or you could create separate title or other fields in your section editor and use the same echo statement approach. As always, there's more than one way to approach any issue.

Hope that helps.

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [sagentic] Print Image Title

Sagentic
Thank you for responding. If I want to upload an image and have its title and/or caption underneath/beside it I would insert the code:

<?php echo $upload['info1'] ?>

Where would I put this code exactly? I understand the principal and even tried it but I'm not sure i placed it in the right place. Can you clear that up for me. Thanks.

Re: [Dan Maitland] Print Image Title

By Kenny - February 23, 2009

Hi Dan -

This is some code that would place the title under the image. It's very simple without any styling.

<!-- STEP 2a: Display Uploads for field 'story_image' (Paste this anywhere inside STEP2 to display uploads) -->
<!-- Upload Fields: num, createdTime, tableName, fieldName, recordNum, preSaveTempId, filePath, filename, extension, thumbFilePath, isImage, hasThumbnail, urlPath, width, height, thumbUrlPath, thumbWidth, thumbHeight, info1, info2, info3, info4, info5 -->
<?php foreach ($galleryRecord['photo'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /></br>

<?php elseif ($upload['isImage']): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /><br>
<?php echo $upload['info1'] ?><br/>

<?php else: ?>
<a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/>

<?php endif ?>
<?php endforeach ?>
<!-- STEP2a: /Display Uploads -->

Pretty much anywhere you have <?php echo $upload['info1'] ?> is where it will show up as long as it is between the foreach and endforeach statements.

Also, make sure you use your specific foreach statement and not mine as your table names and fields may be different.

If this gives you trouble, send your code you have now over, and we can clean it up for you.


Kenny

Re: [sagentic] Print Image Title

I can't thank you enough. Thank you. It works great.

Re: [Dan Maitland] Print Image Title

Hey Kenny... I know I must be doing something wrong... but I'm inserting the code you mentioned in this thread and it's not showing up on the page. The website is http://www.integritymh.com/mezzanine_shelving.php and Here's the code:

<?php foreach ($mezzanine_shelvingRecord['photo'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" />
<?php elseif ($upload['isImage']): ?>
<br/>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /><br /><?php echo $upload['info1'] ?>
<br/>

<?php else: ?>
<a href="<?php echo $upload['urlPath'] ?>"><?php echo $upload['filename'] ?></a><br/>

<?php endif ?>
<?php endforeach ?>
<!-- STEP2a: /Display Uploads -->
John Tedesco

Creative Director



JAM Graphics

Re: [jtedescojam] Print Image Title

By Kenny - March 3, 2009

The code looks good from what I can tell, so the only thing I can think of is to check and see if you have those fields enabled on your uploads.

Under Advanced Options for the "Photos" do you have anything listed next to info1, info2, etc....?


Kenny

Re: [jtedescojam] Print Image Title

By Kenny - March 3, 2009

Glad you got it working.

Try this tutorial I wrote a while back for making your images larger.

http://www.interactivetools.com/forum/gforum.cgi?post=64222#64222

There are many ways to do it, bu this one has some cool effects to it.

Kenny