Uploaded Images
Gautam Patel asks
I want to upload images but there is some html I want generated in each image invariably (not just the standard stuff) -- for example border="0" or align="left" or whatever. How do I hack the MT tmpl files/scripts to do this?
Open the file lib/MT/App/CMS.pm and around line 1902, find the following
my $link = $thumb ? qq(<img src="$thumb" width="$thumb_width" height="$thumb_height" border="0" />) : "View image";
As you can see, for the most part it is simple HTML. To align left, just add the attribute like this
my $link = $thumb ? qq(<img src="$thumb" width="$thumb_width" height="$thumb_height" border="0" align="left" />) : "View image";
There are two other lines you will need to edit in a similar fashion. The first is around line 1910 and looks like this (again you can change the HTML)
<a href="$url"><img alt="$fname" src="$thumb" width="$thumb_width" height="$thumb_height" /></a>
while the second is around line 1914 and looks like this
<img alt="$fname" src="$url" width="$width" height="$height" />
As long as you include all the variable names (words that begin with the dollar sign $ eg $fname) you should be ok. As a precaution, always take a backup of these files in case you do it wrong!

Gautam Patel said:
on Dec 10, 2004 1:19 PM | Reply
Thanks so much!
Dan Wolfgang said:
on Dec 10, 2004 8:42 PM | Reply
As has been pointed out to me, the "correct" way to do something like aligning is with CSS. My recommendation would be to edit the template to include something like 'class="leftimage"' then edit your stylesheet to something like '.leftimage { float : left; }.'
Arvind Satyanarayan said:
on Dec 10, 2004 8:46 PM | Reply
Thanks Dan, that's how I do my image aligning. The example I gave was just a simple one :)
Paul said:
on Feb 25, 2005 2:49 AM | Reply
Great info! I have been scouring every script in my Movable Type directories for the right code to change and was about to give up. Thanks a bunch!
Ted said:
on May 3, 2005 5:59 AM | Reply
What do you edit the CMS.pm file with>
Brad said:
on Jan 27, 2006 5:55 PM | Reply
What if you want to edit the destination the file gets uploaded to?
I am trying to create a foolproof upload process for others. They can't be relied upon to type "images" in the Upload Info text field: / [text field]
So I was hoping I could edit CMS.pm to set "/images" as a default - or, pre-populate the field with the word "images"
I've been trying to edit the following lines of CMS.pm but have had little luck.
if ($q->param('site_path')) { $root_path = $blog->site_path; $relative_path = $q->param('extra_path_site');I think I want to define 'extrapathsite' as equal to "images" but I don't know how to do that. I tried replacing 'extrapathsite' with 'images' but that didn't work. It didn't break anything, but it didn't change anything. Any ideas?
brad said:
on Jan 27, 2006 6:13 PM | Reply
Sorry - I left a comment a moment ago, about changing the default directory for 'file upload.'
I did find the knowledge I needed here: http://www.waywardpuppy.com/archives/2005/06/simplemtuploa.html
I was way off base :-)
Thanks for the resource, your time and trouble, Brad
demonsurfer said:
on Jul 25, 2006 9:10 PM | Reply
For MT3.31, the above lines are located at / around lines 4784, 4791, and 4795.
dave said:
on Jan 8, 2007 7:35 AM | Reply
I'm using MT 3.33. When I alter the cms.pm file I receive the error: "Got an error: MT/App/CMS.pm did not return a true value at (eval 2) line 1."
Any thoughts?
dave said:
on Jan 8, 2007 9:45 PM | Reply
Figured it out!
I don't know if this is an issue with Dreamweaver or not but I have come to the realization that it is not possible to replace an existing cms.pm through a simple save. With that said, Dreamweaver's file manager setup allows you to save over top of an existing file. Attempting to replace the cms.pm file through this uploading action results in the corrupt file I indicated above. So first rename your original cms.pm file to something like cms2.pm. Then edit cms2.pm and save it back as a cms.pm.
Now I can apply my style. Thanks for this great hint.
RJ said:
on Jan 12, 2007 4:40 PM | Reply
Arvind.
Elise's LMT and your Movalog have been THE Knowledge source, the 'Force' that is always with us! Thank you for all the help you have shared.
I like the way your commenting and the instant preview with the 'security' word set up. How did you do it? Is there a code template somewhere for this. I like the clean and crisp layout of this set up.
Thanks