File and Image Uploads
One of the types of fields in the Program is the Upload field. An Upload field
gives your user the ability to upload a file - usually images, but sometimes
other documents like PDF's or DOC files.
When you put an upload field's placeholder into the template you will also
need to create a corresponding templateCell for that field. The name for
the templateCell is $PLACEHOLDER.row$.
Example:
$foo$
<!-- templateCell : foo.row -->
<etc...>
<!-- /templateCell : foo.row -->
Attributes
See the "Attributes" section for a full list of upload attributes
Uploaded files have a lot of different data related to them ("attributes"): images have width, height,
and filename; a PDF or Word document has filename but not height or width. To the Program, other data are
considered attributes, such as the URL to the uploaded image, and any values entered by the user (such as
Caption, title, image alignment).
Attributes for an uploaded file can only be called from its templateCell. The format for the attribute placeholders is $file.ATTRIBUTE$, where ATTRIBUTE is the name of the specific attribute you want:
Example:
The following templateCell is used for the placeholder $uploadedImage$.
<!-- templateCell : uploadedImage.row -->
<img src="$file.webUrl$" width="$file.width$" align="$file.align$">
<!-- /templateCell : uploadedImage.row -->
Embedded Media
Some uploaded fields are designed so that the files can be used in the content of
other fields. For these "Embedded Media" fields, you don't put a placeholder in your
templates: instead, users will put a special placeholder in the content of another field
corresponding to the file they've uploaded, such as ***image1***.
Some notes:
- After uploading files for Embedded Media, the user will have a list of appropriate placeholders to paste into the content.
- Embedded Media are formatted by the templateCell default.embeddedMedia, located
in templates/common/embeddedMedia.html
- If you're using both image and documents in Embedded Media, you may want to use a "templateIf" to format images differently from and other file types.
The example below shows how this could be done (see the "templateIf" command docs for more information).
1 <!-- templateCell : default.embeddedMedia -->
2
3 <!-- templateIf : $file.isImage$ == "1" -->
4 <img src="$file.thumbnailWebUrl$" alt="$file.title$">
5 <!-- /templateIf -->
6
7 <!-- templateIf : $file.isImage$ != "1" -->
8 <p>[ <a href="$file.webUrl$">Download $file.title$</a> ]</p>
9 <!-- /templateIf -->
10
11 <!-- /templateCell : default.embeddedMedia -->
(Note that this example is simplified from a typical default.embeddedmedia templateCell.)
- If you want override the default format that appears in templates/common/embeddedMedia.html, you can put a custom templateCell in an individual template. This will override the format for embedded media in that template only, and only for tags inserted into a specific field.
This templateCell is named $SPECIFIED_FIELD.embeddedMedia$, where the SPECIFIED_FIELD is the placeholder for the field that will contain the embedded media tags (not the name of the upload field itself!).
For example, for an embedded media upload field called "image" (that uses the ***image1***, ***image2***, etc. tags) you might want to override the default.embeddeMedia template when the ***image#*** tags are put into the "Promo Description" field. To do this, you'd add the following code to the templates in which you want to override the format:
1 <!-- templateCell : article.promoDescription.embeddedMedia -->
2
3 <div class="promoDescriptionPhotos">
4 <img src="$file.thumbnailWebUrl$" alt="$file.title$">
5 </div>
6
7 <!-- /templateCell : article.promoDescription.embeddedMedia -->
|