FIX FOR DISPLAYING VERY NARROW IMAGES IN EDITOR UPLOAD FIELD (THINK HORIZONTAL GRADIENTS) - Apr 25th, 2013


I was having a devil of a time displaying a tall skinny .jpg (10px x 500px) that I'm using as a page background
gradient.

Instead of a small thumbnail displayed in my editor upload field I was getting a really tall thumbnail and had to scroll
the thumbnail to see the bottom of it (or the “remove” link)?.

Fortunately Jason Sauchuk from Interactive Tools had some insights and a fix.

He said:

"The reason for this is that the image CMS Builder displays inside the record editor comes from a function called
showUploadPreview().

In this function, a width for the preview image is set. This has been hard coded to use a width of 50 in the function
call. So if your image has dimensions of 10 X 500, it has an aspect ratio of 1:50. So if the preview image is given a
width of 50, it has a height of 2500!

If you want to override this to use the thumbnail width, here is some code to do this. Please note that I tried this
change through version 2.50, and if you upgrade your installation, this change will be overwritten.

Open up cmsAdmin/lib/menus/default/uploadList.php. Around line 101 you should see this:



<?php showUploadPreview($row, 50); ?>


You can make this change to it:


<?php

$width = 50;
if (
$row['isImage'] && $row['hasThumbnail']) {
$width = $row['thumbWidth'];
}
?>
<?php showUploadPreview($row, $width); ?>


this will use the images first thumbnail width. If a thumbnail doesn't exist, it will default back to 50."



That takes care of the editor upload field,. To fix the Record List view, Damon Edis from Interactive Tools offered:

The file you want to modify is list_functions.php. At: /cmsAdmin/lib/menus/default/list_functions.php

Again, make a backup of that file first, just in case.

At (or around) line 575 there is the line:


showUploadPreview($upload, 50);


You can change the 50 to be another number, or to have it show the thumbnails actual size replace the line with this:


showUploadPreview($upload, $upload['thumbWidth']);


Note: Any change to CMS Builder code will be overwritten in an upgrade so it is a good idea to create a custom code
change text log so that you can make these changes again in the future if needed



The materials on this web site have been created for use with CMS Builder content management software. CMS Builder software is published and licensed for use by InteractiveTools.com. Please contact Interactive Tools for information on the downloading of the software or the purchasing of licenses.


Terms of Service