Limit Upload Display - Mind Blank!

5 posts by 4 authors in: Forums > CMS Builder
Last Post: November 2, 2008   (RSS)

Re: [Perchpole] Limit Upload Display - Mind Blank!

By Kenny - September 21, 2008 - edited: September 21, 2008

Perch,

The easiest thing I have found to do is to make a seperate "preview image" upload field. This way the user can choose which picture to show as the preview image. Limit this field to a one picture upload and code just this upload field into your list page.

I know this means you have to upload the same picture twice (once as a preview image and once as a gallery image) but it does make it understandable for most users.

As far as making this automatic, I haven't ever tried to code that so I'm not much help there.

Kenny

Re: [sagentic] Limit Upload Display - Mind Blank!

Hi, Kenny -

Thanks for your input. I've already gone down the route you suggested but (as you hi lighted) it seems like an necessarily repetitive step!

Ideally I'd like to be able to pluck out a random upload/image from the record and display it next to each entry on the listpage.

As with all things related to my CMS projects, I want to make the admin as easy (and as automated) as possible for the end-user - the client.

:o)

Perchpole

Re: [Perchpole] Limit Upload Display - Mind Blank!

By Dave - September 22, 2008

Hi perchpole,

If you know all your uploads are images and will have thumbnails you can remove this code:

<?php foreach ($record['gallery_images'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" />
<?php endif ?>
<?php endforeach ?>


Next, if you want to show just one image you can use break like this to stop after just one:

<?php foreach ($record['gallery_images'] as $upload): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" />
<?php break ?>
<?php endforeach ?>


And if you want a random image you can shuffle your array first:

<?php shuffle($record['gallery_images']) ?>
<?php foreach ($record['gallery_images'] as $upload): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" />
<?php break ?>
<?php endforeach ?>


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

Re: [Dave] Limit Upload Display - Mind Blank!

Thank you!