Embedded Movable Type Photo Gallery
Update: this post is broken due to my move over to WordPress. I’ll be building a similar plugin for WordPress. MT users… sorry.
A few months ago, I wrote about my search for a simple web based photo gallery. Since then, I’ve been using Qdig. Qdig is a basic photo gallery that is dynamically generated based on images stored in one or more directories. It will auto generate the image navigation, resize your images, and create your thumbnails. No need for a database or any fancy settings. Qdig is basically one PHP script that does all of this.
One of the nice features of Qdig I never took advantage of until now is it’s ability for it to be “included” within other PHP pages. Since my site runs on PHP, I was able to include Qdig into my entries as an embedded photo gallery. Like the example below (photos of our bathroom remodel):
To get this to work cleanly with Moveable Type, I created a macro using Brad Choate’s MTMacro.
<MTMacroDefine name=”qdig” tag=”qdig”>
<?php $chroot_dir = “<MTMacroAttr name=’path’>”;
if (strtolower(”<MTMacroAttr name=’normalize’>”) == “true”) {
$normalize = “-normalize”;
} else {
$normalize = “”;
}
include “/path_to_qdig_script/qdig.php”;?>
</MTMacroDefine>
This allows me to easily create a quick ad-hoc photo gallery within my entries like the one above by simply using the following markup within my entries:
<qdig path=”path/to/your/images/”>
I added the normalize attribute in there to allow me to have ImageMagick convert my images with the “-normalize” attribute which transforms images to span the full range of colors found in the photo (similar to the “Auto-Levels” command in Photoshop).
To get this to work the way I wanted, I had to modify Qdig a little bit so that the markup tags it created were identified with class names so I could apply some simple CSS to it. Here’s the qdig.php file with my customizations. To add the scrollbar effect win the thumbnails, I used the overflow and white-space property in css. View my stylesheet if you’re interested to see how I did it (look in the “gallery” section).
April 14th, 2004 at 8:04 AM PDT
Love the use of QDig - can’t get it working on my site, am a newbie to MT, and basically learning everything as I go - where do I define the MT tags? Does this go in the index.php template? Does it matter where?
April 15th, 2004 at 8:36 AM PDT
You can add the MT tags in the MT templates. Read this for a tutorial on templates:
http://www.movabletype.org/docs/mtmanual_templates.html
May 11th, 2004 at 8:53 AM PDT
Love the scrollbar idea for qdig. I borrowed your css and threw it in my index.php for qdig. It seemed to have worked, but now it still wraps some thumbnails, so they don’t all stay up in the scrollbar area. Any ideas as to what I should do to fix it? If you want to see what I’m talking about, my qdig gallery is at http://www.rapidnet.com/~zarxic/blog/pics
Thanks again, great site.
May 12th, 2004 at 1:56 AM PDT
Maybe I’m missing something, I’m able to include the initial page. Just using @ include ‘path/qdig.php’; but when I click to view the next image I get the plain qdig.php not embedded.
What am I doing wrong here?
May 12th, 2004 at 3:04 AM PDT
jharr, when you include qdig.php into your “wrapper” php page, all you’re doing is adding that qdig functionality within the page you want it to fit into. In my case, the page I wanted to fit qdig into is this php page (embedded_movable_type_photo_gallery.php).
When you click on the images, the hyperlinks should be pointing back to the original “wrapper” page.
Does this make sense? It’s a little tough to explain.
May 12th, 2004 at 4:20 AM PDT
So do you reference the original qdig.php file in the include or do you paste the qdig contents into tat page? I haven’t seen any decent documentation on how this is done.
Do I need to somehow modfiy the base qdig file to make this work or should I just be able to reference it as an include?
I’ve built several robust apps in PHP, yet this little script has given me quite a bit of heartburn. It’s the best, most simple photo gallery php script I’ve seen, I just wish I could get it to integrate well with my site.
May 12th, 2004 at 4:52 AM PDT
jharr, by “include” I mean, use the php function include(). For example, the php code for this page has a line in it like this:
<?php include ‘/path/to/qdig.php’?>
Make sense?
May 13th, 2004 at 3:50 AM PDT
Thanks Rich. That’s exactly what I’ve been doing, however I am still missing something that makes this work correctly. I’ll keep digging.
May 13th, 2004 at 9:25 AM PDT
Rich, I managed to get this working, there’s some issue with the qdig base file I was using. I still have no idea where the glitch was, maybe it was in one of the half dozen qdig/index.php files I was using at any given time. Thanks for your help and for the great MT example.
February 4th, 2005 at 4:17 AM PST
Rich,
Someone else is also trying to integrate Qdig into WordPress. I recently added something to the script to help with that. Here’s the forum thread. Let me know if you have any suggestions for making Qdig WordPress-comaptible.