Little Help with Images

8 posts by 2 authors in: Forums > CMS Builder
Last Post: May 12, 2008   (RSS)

By dparrott - May 9, 2008

Hello, I'm needing a little help with images.
I'm trying to understand how they work. Here is my understanding (which may be totally off base):
To have images on my site I upload them, both a smaller thumbnail and larger image of the same.
If that is the case how do I get it so that on the detail (or single item page) the user can click on the thumbnail to see the larger image?
Can this work with multiple images on the same detail page?

thanks
dale

Re: [dparrott] Little Help with Images

By Dave - May 9, 2008

Dale, welcome to the forum, we're here to help! :)

You can upload images through either a wysiwyg field or an upload field. And the program will automatically resize it (if it's oversized) and create a thumbnail as well. So you only need to upload an image once. You can control the resizing and thumbnailing options for each field in the field editor.

To link a thumbnail to a large image in the wysiwyg you'd do as follows: You'd click the image button (looks like a tree), then the browse button beside "image url" and upload your image. Then click "small" to insert a small version. Then click on the image in the wysiwyg and click the link button. Click browse beside "Link Url" and you'll see your upload, then click "large" to insert a link to the large version.

If you're using an upload field and you want images displayed automatically you'd do as follows (this is for the latest version 1.15, but earlier version are similar):

<?php foreach ($newsRecord['uploads'] as $upload): ?>

<a href="<?php echo $upload['urlPath'] ?>">
<img src="<?php echo $upload['thumbUrlPath'] ?>"
width="<?php echo $upload['thumbWidth'] ?>"
height="<?php echo $upload['thumbHeight'] ?>"
alt="" /></a><br/>

<?php endforeach ?>


Note that you're record variable may be named something other than "newsRecord", just use whatever name is already in the code. The $upload part is usually the same. Basically there's a list of available fields: urlPath, height, width, thumbUrlPath, thumbWidth, thumbHeight, etc and you can display any of them with a tag like this: <?php echo $upload['thumbHeight'] ?>. So we display the url of the big image 'urlPath' in the a href tag and the url to the thumbnail 'thumbUrlPath' in the image tag.

You should be able to do most of that by just moving around the code generated by the code generator.

Hope that helps. Let me know if you need any more detail on any of that. :)
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Little Help with Images

By dparrott - May 12, 2008

That did the trick Dave thank you very much. Is there a way I can get multiple thumbnail images to display in a row rather than one above the other?

Re: [dparrott] Little Help with Images

By dparrott - May 12, 2008

Nevermind Dave. I found an offending <br> in there... sorry.
thanks for the help

Re: [dparrott] Little Help with Images

By Dave - May 12, 2008

I just about to post too, but you beat me to it. Glad you figured it out! :)
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Little Help with Images

By dparrott - May 12, 2008

Things are going pretty well Dave, but I need a little help with the images on my List page. The page currently pulls in all thumbnails for a product and I want it only to pull one in. Here is the code that I have

<?php // foreach (getUploads($options['tableName'], 'images', $record['num']) as $upload): ?>
<?php $upload = getUploads($options['tableName'], 'images', $record['num']); ?>
<a href="<?php echo $record['_link'] ?>">
<img src="<?php echo $upload['thumbUrlPath'] ?>"
width="<?php echo $upload['thumbWidth'] ?>"
height="<?php echo $upload['thumbHeight'] ?>"
alt="" /></a>

<?php // endforeach ?>


I took the foreach statement out, but that didnt' seem to help.

does this make sense?

thanks
dale

Re: [dparrott] Little Help with Images

By Dave - May 12, 2008

Using the foreach just add this tag before the "endforeach", like this:

<?php break; ?>
<?php endforeach; ?>


"break" just means "stop looping over images". That should show 1 and then stop.

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com