Blosxom: How to insert a fixed path for images in Blosxom
I wrote some post on my new site created with Blosxom and I wanted to insert some images that I put in a directory called
images under my website address root.I found different solutions:
- I pointed the image link to the absolute web address of the images directory, like this:
<img src = "http://mydomain.org/images/filename.jpg">.
That means if I change domain I would have to change each post I've done (obviously, I would use an automatic tool or script to search and replace multiple files at a time). - A slightly more versatile solution would be to point the image link to something like
../../images/filename.jpg, with one../for each level of the category tree I have to go up to reachindex.cgi. This means I would point to../images/in some posts, to../../images/in some other posts, to../../../images/in even other posts.
This solution is error-prone and if I decide to move a post into another category that sits on another level I would have to change all the image links in that post. - The solution I adopted is to store the absolute web address of the images directory into a variable in
index.cgiand use it in my posts. This is what I did to make it work:- I added
$imagesurl = "http://mydomain.org/images";right below$url = "";inindex.cgi - Again in
index.cgi, in the first line after configuration settings (use vars qw! $version ...) I added$imagesurlin the variable string - Always in
index.cgiI edited the block where the post file is read:
if (-f "$path_file" && $fh->open("< $path_file")) { chomp($title = <$fh>); chomp($body = join '', <$fh>); $fh->close; $body =~ s/\$The line I added is theimagesurl/$imagesurl/g; $raw = "$title\n$body"; }$body =~ s/\$imagesurl/$imagesurl/g;, telling the cgi to substitute in the body read from the file the string$imagesurlwith the content ofimagesurlvariable. - Finally, I changed my image links to
<img src = "$imagesurl/filename.jpg">.
- I added
Posted by: Z24 | Sun, Sep 10 2006 |
Category: /configurations/both |
Permanent link |
home
Tagged as: bloxsom, configuration
http://www.mycomputingart.com/
To contact the webmaster and author write to: info<at>mycomputingart<dot>com
© mycomputingart.com, year(today()).


