Another image rotator question

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

By Codee - February 27, 2008

Dave and Co.,

Is it possible with CMS builder to have upload images go to one directory and for the built thumbnails to be placed into another directory? If I want to use a simple dynamic script to pull all the thumbnail images only to display onto an image rotator, then only the thumbnail images need to be in a separate directory.

Re: [equinox69] Another image rotator question

By Dave - February 27, 2008

Sure, we've had two requests for that now. I've added it to v1.10.

If you are comfortable modifying PHP code and want to add it to your v1.09 right away, you can try this:

Open /lib/menus/default/uploadForm_functions.php. Save a backup copy of this file first. Then search for "_thumb" (that should only match one line) and replace that line with this:

$thumbSavePath = $createThumbnail ? preg_replace("|([^/]+)$|", "thumb/$1", $uploadSavePath) : "";

Then search for "$uploadUrl, $thumbSavePath" (that should only match one line) and replace that line with this:

$thumbUrl = $createThumbnail ? preg_replace("|([^/]+)$|", "thumb/$1", $fileUploadUrl) : "";

Then search for "open source image" (that should only match one line) and replace that line with this:

// create target dir
$dir = dirname($targetPath);
if (!file_exists($dir)) { mkdir_recursive($dir); }


// open source image


That will make it so all thumbnails created after that change will be created with the same filename in a subdirectory called "/thumb/" under the upload dir.

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

Problem came up, Re: [Dave] Another image rotator question

By Codee - February 29, 2008 - edited: March 30, 2013

Hi Dave,
I did exactly as you said in the posted reply for modifying the code. I got errors stating the directory could not be created but realized it was a permissions issue. I manually created the directory (/thumb/) and changed the permissions to it and it works.

However, when I went to delete the new test record, I got this message from the admin screen:
The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.

"
--------------------------------------------------------------------------------

Only one top level element is allowed in an XML document. Error processing resource 'http://www.domainname.com/cmsAdm...

<b>Notice</b>: Use of undefined constant mysql_affected_rows - assumed 'mysql_affected_rows' in <b>/usr/h...
"

I can hit "back" on the browser and the listing is deleted but the error needs not to occur and the customer won't accept this of course.

Am I relegated to restoring the original uploadForm_functions.php page? I really need the thumbnails in a separate directory.

Re: [Dave] Problem came up, Re: [Dave] Another image rotator question

By Codee - February 29, 2008

Dave,

Solid. Worked perfectly.

Thanks again!

Terry