Something that annoys me a little about WordPress — that has changed between v.1.2 and the latest v.1.5 — is the code it automatically generates for uploaded image files.
When you Upload a file WordPress automatically generates the XHTML code for you, so that you can simply copy and paste it into a post or page, for example:
<img src='https://www.garethjmsaunders.co.uk/wp-content/image.jpg' alt='Description of image here' />
But you will notice that it has surrounded the URL and alt description with single quotation marks (') rather than double ("). I'm a fan of double-quotation marks here. So I've made a simple hack to the upload code:
How to hack upload.php
Here's how to change the code in your WordPress 1.5 installation to ensure that it will always give you double-quotation marks (") in the auto-generated XHTML code:
- The code for uploading files is contained in the file
wp-admin/upload.php within your WordPress installation.
- Open the file in your text editor of choice (I prefer 1st Page 2000) and scroll down to about line 202
- There you will see the following lines of code:
$piece_of_code = "<img src='" . get_settings('fileupload_url') ."/$img1_name' alt='$imgdesc' />";
$piece_of_code = "<a href='". get_settings('fileupload_url') . "/$img1_name' title='$imgdesc'>$imgdesc</a>";
- Simply replace these lines with the following:
$piece_of_code = "<img src=\"" . get_settings('fileupload_url') ."/$img1_name\" alt=\"$imgdesc\" />";
$piece_of_code = "<a href=\"". get_settings('fileupload_url') . "/$img1_name\" title=\"$imgdesc\">$imgdesc</a>";
- You will notice the subtle alteration of escaped quotation marks (\") replacing the previous single quotation marks ('). The backslash before the quote tells PHP to regard the quotation mark as a text character rather than as part of the syntax of the code.
- Now save this file, and upload it (no pun intended) to your WordPress installation.
- that's it!
Here’s an interesting find. I did a search on Amazon for Drupal and found this yet-to-be-published book, from APress:
Building Online Communities with Drupal, phpBB, and WordPress, by Robert T. Douglass, Mike Little and Jared W. Smith (APress, November 2005, ISBN 1-59059-562-9).
(The hyperlinks point to the Apress website, not Amazon UK.)
Two technologies that I already use (phpBB and WordPress) and one that I’d like to learn more about (Drupal).
It’s been a long, long week. I’m still battling this wretched virus that has laid me low for the best/worst part of a month. On top of that I’ve had a rather sleepless week trying to get the new Scottish Episcopal Church website up and running for the start of General Synod, which began today in Glasgow.
I managed it, however, and carefully guided through the transition from one server to the other at around 02:00 this morning, updated the CMS options and rewrote the .htaccess file by hand and uploaded it to the server. I went to bed this morning while the sun was rising. (Seemingly Jane had a coughing fit in the night and I asked her if she was ok and could I get her anything. I don’t remember any of that, but it was nice to see that in my exhausted and unconscious state I was still concerned about my wife.)
Sadly, the only feedback I’ve had today about the website was negative. It really upset me, and spoiled much of the rest of the day. Kind of made me wonder why I even bother sometimes!
I’ve begun reading PostNuke Content Management by Kevin Hatch
(Buy at Amazon.co.uk / Publisher’s website)
Having struggled to learn any Content Management System (CMS) from online tutorials and half-written documentation I was pleased to read that Kevin Hatch also regards much of the available documentation confusing. (He’s not the only one, Jeffrey Veen vents his spleen in this article on his blog.)
I’m hopeful. The book is very readable, and includes a number of real-life practical examples of how to set up PostNuke sites — something that is sorely missing from the online manuals. My hope is that this book will help me get my head around the theory behind how CMSs work, and that it will aid me to get to grips with not only PostNuke, but Drupal and even WordPress, from which this blog is powered. I’ll let you know how I get on.