Image previews in the content editor in 6.5.2

I don’t know about you folks, but when I’m uploading a sys_File and it’s an image, I sort of expect to see a version of that image in the editor after it’s been saved. Here’s one method to do just that in 6.5.2.

Your content type should have a sys_File field and several supporting fields such that the Pre-processing Item Transform sys_imageInfoExtractor() can fill in height, width and type fields.

[li]New shared template, “BinaryIsValid” (source attached) - this template should not be visible to any community or site.
[/li][li]additions to rx_resources/stylesheets/rx_Templates.xsl (attached). You can change the server address and preview size in this code, if needed.
[/li][li]add the BinaryIsValid template to any content type that has a sys_File type control. (if you neglect this step, the XSL change will default back to the out-of-the-box behavior)

These modifications will change the behavior of sys_File controls such that:
[li]Fields with an empty value will have no preview link or clear checkbox.
[/li][li]Fields with a *_thumbnail sister field will display the thumbnail instead of the “Preview File” text (use PSOThumbnailGenerator to fill this field).
[/li][li]Fields with image values and no thumbnail will display the image scaled to a preview size (using browser-level scaling) instead of the “Preview File” text.
[/li][li]Any preview image displayed can be clicked on for a full-size version of the original image (i.e. the preview link is still intact).
[/li][li]Works for images in both the main and child tables

If someone could test this in a more recent version and post here your results, that would be fantastic.

Correction for BinaryIsValid template:

line 29 should read:

<isvalid thumbnail="$thumbnail" type="$type" height="$height" width="$width">yes</isvalid>

Also works in 6.7.

Another correction: any instance of $submitname_ needs to be replaced with ${submitname)_ in the template

Implemented in 7.2 without any major modification of this code.

There is, however, a bug in either Rx, or PSO’s helptext code that breaks the links… I’ve outlined it here.