On a path a Michelle Jones type situation

Posted
27 September 2007 @ 11am

Tagged
Movable Type, technology

How To Change the Default Image Upload Location in Movable Type 4.0

I’ve started a new site called Correspondence Notes. The site is about written communication as well as the tools and materials that go along with it. It contains lots of fawning over and geeking out about stationery and note cards. Like all of my sites Correspondence Notes is powered by Movable Type.
Nearly every article for Correspondence Notes contains at least one image. I use Movable Type’s built in upload feature to upload images and add them to entries. The process is fine except for one step. By default Movable Type will upload images to your Site Root. That’s great except I like my images to go into a subdirectory I like to call…images. I can of course, with the file upload utility, tell Movable Type to put the images into the images subdirectory. The problem is that the utility will not remember this preference. Every time I upload an image I have to tell Movable Type again to put the new image in the images directory instead of the Site Root. Though it only takes a few key strokes to type “images” into the subdirectory field it’s a silly time waster since I want every single image I upload to go into that folder.
Since there isn’t an option within the Movable Type user interface to make the file upload utility remember that I want my images to always go into the images subdirectory I decided to go straight to the source and make it happen. Please remember that if these steps break your copy of Movable Type I’m not the least bit responsible.
Configuring the upload utility to upload to the same subdirectory by default is actually quite simple. It only requires editing a single line of a single .tmpl file. However, if monkeying with an application’s source code makes you really nervous I’ve heard there is a great plugin for improving Movable Type’s file upload utility that only costs $10.
The file to edit is called asset_upload.tmpl. Assuming you have your Movable Type files in your cgi-bin the path to this file looks something like cgi-bin/mt/tmpl/cms/dialog/asset_upload.tmpl.
1. Download asset_upload.tmpl (I highly recommend you save a backup copy of it before you edit it)
2. Open asset_upload.tmpl and look for the following:
/ <input name="extra_path" id="extra_path" value="<mt:var name="extra_path" escape="html">" />

3. Change
value="<mt:var name="extra_path" escape="html">"
to
value="images"
where “images” is whatever subdirectory name you want your images uploaded to by default.
So your final code should look like this

/ <input name="extra_path" id="extra_path" value="images" />

4. Save and upload asset_upload.tmpl
5. Upload an image
uploadedit.png
You’ll notice that the subdirectory field is still completely editable. So while Movable Type will, by default, now upload my images to the images subdirectory, should I want to upload a particular image to a different directory all I have to do is type a different name into the subdirectory text box.


No Comments Yet


There are no comments yet. You could be the first!

Leave a Comment