Displaying Uploads
For most fields, displaying a value only takes a single tag. Uploads are different: each upload carries multiple pieces of information (URL, width, height, thumbnails, captions), and a field can hold multiple uploads, so viewers loop over them.
Basic structure
Section titled “Basic structure”The generator produces a block like this for each upload field (a field named
images in this example):
<!-- STEP 2a: Display Uploads for field 'images' (Paste this anywhere inside STEP2 to display uploads) --><?php foreach ($record['images'] as $index => $upload): ?>
... each upload is displayed here ...
<?php endforeach ?>Inside the loop, display upload attributes the same way as record fields:
<?php echo $upload['urlPath'] ?>Uploads are returned in the order they appear in the record editor, where they can be re-arranged by drag-sorting.
Example: thumbnails linked to full-size images
Section titled “Example: thumbnails linked to full-size images”For a clickable gallery, wrap each thumbnail in a link to the full-size
image’s urlPath:
<?php foreach ($record['images'] as $upload): ?> <?php if ($upload['hasThumbnail']): ?> <a href="<?php echo $upload['urlPath'] ?>"> <img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="<?php echo $upload['info1'] ?>"> </a> <?php endif ?><?php endforeach ?>Upload attributes
Section titled “Upload attributes”All uploads
Section titled “All uploads”| Attribute | Description |
|---|---|
filePath | Server path to the uploaded file, e.g. /var/www/example.com/cmsb/uploads/photo.jpg |
urlPath | Website location of the file, e.g. /cmsb/uploads/photo.jpg |
filename | The file name, e.g. photo.jpg |
extension | File extension, e.g. jpg |
isImage | 1 if the file is an image (gif, jpg, jpeg, png, or webp) |
filesize | File size in bytes |
Info fields
Section titled “Info fields”| Attribute | Description |
|---|---|
info1, info2, … | Extra per-upload fields defined in the field editor. By default info1 is “Title” and info2 is “Caption” — useful for alt text, file descriptions, or gallery captions. |
To change the info field labels, go to CMS Setup > Database Editor, click modify beside the upload field, and find the Upload Fields settings.
Images
Section titled “Images”| Attribute | Description |
|---|---|
hasThumbnail | 1 if the upload is an image with a generated thumbnail |
width, height | Dimensions of the uploaded image |
thumbUrlPath | Website location of the generated thumbnail (thumbUrlPath2–thumbUrlPath4 for additional thumbnail sizes) |
thumbFilePath | Server path to the thumbnail (thumbFilePath2–thumbFilePath4 for additional sizes) |
thumbWidth, thumbHeight | Thumbnail dimensions (thumbWidth2/thumbHeight2 etc. for additional sizes) |
Miscellaneous
Section titled “Miscellaneous”These attributes are used internally by the program and are listed for completeness:
| Attribute | Description |
|---|---|
order | Position of the upload within the field, set by drag-sorting uploads in the editor |
mediaNum | Record number of the linked Media Library file, when the upload references one |
storage | Identifier of the storage backend holding the file |
num, createdTime, tableName, fieldName, recordNum, preSaveTempId | Internal bookkeeping values |