Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
How to deal with a large number of images in Textpattern?
I am currently working on a gallery-admin plugin that is a port of an external script. This script uses individual directories for each album to store images. There can be a large number of images. Most of them will never be referenced from an article, they are only shown in the gallery.
This leads to the question: How to deal with a large number of images (or files/assets) in Textpattern?
Especially when they are not referenced often from articles. Should they all be imported into the images/files directories or should the better be kept in separate directories?
The current plugin implementation is compatible with my older external script, so it keeps albums and pictures at the original locations and does not import them into the images directory. But i am not sure if this is a ‘best practice’ or not.
Offline
Re: How to deal with a large number of images in Textpattern?
Hello Andreas,
If I understand your question correctly, you are developing a plugin that will circumvent the current Textpattern method of storing images in a single directory on the server. While I wouldn’t want to discourage you, I wonder if the notion of albums and directories can ever provide the basis of a ‘best practice’ in or out of Textpattern. Two professional photographers I know, persuaded me that ‘Albums’ and ‘Directories’ are superfluous pieces of meta information when it comes to storing images, especially when it creates a system that requires multiple paths/locations. They prefer to store their thousands of stock images in a single location and use tags/labels to categorize each one.
You likely could go ahead and build your website using something approaching ‘best practice’ without developing your plugin and using existing tools. As you know, Textpattern permits you to allocate each image to a category and you can organize categories into ‘parents’ and ‘children’ and use those to select your gallery sets of images. The plugin jbx_multiple_image_upload enables you to allocate a group of images to a category as you upload them.
Being able to have only one category (i.e. ‘tag’) per image is limiting but you could use the plugin smd_tags to extend that if you need to.
Another great advantage of storing images in a single location is that you can use the Textpattern ‘ihu’ configuration constant in config.php to facilitate parallel delivery of images to web sites. See the discussion here“http://forum.textpattern.com/viewtopic.php?id=34493&p=1 for instance.
I hope this helps. I am sure that others may not necessarily agree with me and indeed may be ‘gagging’ for a plugin along the lines of the one you are developing to store Textpattern images in a system of folders/albums.
Last edited by joebaich (2011-09-24 16:14:24)
Offline
Re: How to deal with a large number of images in Textpattern?
… and just to be clear, if you won’t really be doing much with those images from within your textpattern setup, other scripts generally co-exist happily alongside textpattern. I’ve done setups before with photostack (now sadly defunct) in its own directory with its own set of subdirectories and then just styled the templates to look part of the same site. You can’t manage your other photos through textpattern but then again, txp is not ideal for managing large numbers of images.
If you want parts of the site to the be same, one approach is to use txp for most of the site’s design and rah_external_output to output snippets for the headers, footers, menu etc. that you can then pull into your gallery script’s template using an include.
Similarly, if you want to reference images from your own gallery from within txp, you could use a custom field in a manner similar to article_image to enter a link to that image – or the image name – etc. and then make your template create the correct link. Alternatively, if you need links in the body field of your textpattern articles, you can either link directly with !/gallery/image-path/image-name.jpg!
or if you need it more involved than that, use smd_macro to create an own tag that does the necessary trickery to reach the image you want.
Finally, if your other script uses a mysql database and doesn’t conflict in its naming with txp, you can use smd_query to query your own database from within txp (prerequisite is that they share a db connection). You could use that, for example, to build a list of category links in txp from the category data in your own db.
In short, there are various possibilities without having to rewrite txp’s image storage paradigm.
Last edited by jakob (2011-09-25 06:22:33)
TXP Builders – finely-crafted code, design and txp
Offline
Re: How to deal with a large number of images in Textpattern?
Hello Joe and Jakob
Thanks for the Tips! This helps a lot.
I have seen, that custom fields could be used to show images or albums together with an article. I also found that fpx_image_import and smd_macro may be useful. But i see now there are a even more options too. :) For example, i wasn’t aware of the !-notation for linking images.
Joe: I do not really want to circumvent something in Textpattern. It has just historical reasons. Originally, i made that script to add a gallery to a static website (Lisa Bahr Photography). It’s a really simple solution, so it lacks a lot (e.g. tags, categories). Album- and image-titles are stored in simple text-files.
Meanwhile, i have re-created that site with Textpattern, including the gallery. Add ‘_test/’ to the above link to see the Textpattern driven site…
For the gallery, i made four plugins: gallery admin, image-uploader, front-side rendering and a library with shared functions. Currently, they have the same functionality as the original solution (plus a few minor improvements) and use the same data (folders, images and text-files with some metadata). I hope i have the time to publish these plugins within the next weeks.
I asked because i wanted to know, in wich direction future development should go.
After thinking about your responses, i see the following improvements:- using the database for storing album- and image-metadata (elimiating those text-files)
- leaving the images where they are but allow import of images for use in articles
- finding a way to assign tags and categories to images (maybe by using a table similar to textpatterns image table)
- test if smd_gallery could be used for the front-side rendering, because it offers a lot more rendering options as my own plugin
Hope this is the right way. The first release will likely not include all of these changes, but the future is open…
Offline