WordPress Attachments – Part 1

A powerful tool that is vastly underused, attachments in WordPress offer many opportunities for great plug-ins. For example, many complain about WordPress lacking a good integrated image gallery. Various solutions exist (e.g., zen photo, gallery, etc.), however none of them offer deep integration into WordPress. The way WordPress deals with attachments changed greatly in 2.0, and since then, the attachment API has gone mostly undocumented, a real bummer for plug-in developers.

“No API documentation, how am I supposed to use them then?”

Fear not, however, Michael Adams, in his blog listed the available API functions for attachments last December.

“But wait, that was almost a year ago, and that was WordPress 2.0, we’re at 2.3 now.”

Don’t worry I’ve tested the functions he offered and I’m going to do some documentation in this post and an few others. Let’s start with the list of functions that still exist in the attachment API for WordPress 2.3.

  • get_attachment_icon([$ID])
  • wp_get_attachment_url([$ID])
  • wp_attachment_is_image([$ID])
  • wp_mime_type_icon()
  • wp_get_attachment_metadata()
  • wp_update_attachment_metadata()
  • get_attached_file()
  • update_attached_file()

string get_attachment_icon([$ID]) returns code for the attachment’s thumbnail (if applicable). The id of the attachment may be specified, if it is not the current (page/post/attachment) id will be used.

string wp_get_attachment_url([$ID]) returns the URL to the attachment (the file not page). Again the id of the attachment may be specified, otherwise it defaults to the current (page/post/attachment) id.

bool wp_attachment_is_image([$ID]) returns true if the attachment is an image, or false if not. Once again the id of the attachment may be specified, otherwise the function defaults to the current (page/post/attachment) id.

Note that I document functions including their return type, this is because it is useful when some functions echo out data instead of returning it. This is only part one, time permitting, next week part two will be released with an investigation into the next tree API functions on the list. I am currently working on a project that will be making extensive use of attachments, and will keep exploring them as work on the project progresses. Additionally look for a simple WordPress attachment based gallery system appearing in the future (around the time WordPress 2.4 is released since a bugfix in WordPress is necessary for some permalink structures).

-John Havlik

[end of transmission, stay tuned]

Breadcrumb Navigation XT 1.10.0

Now with 100% more tags. That’s right, WordPres 2.3 is right around the metaphorical corner, and in preparation Breadcrumb Navigation XT 1.10.0 is now safe for general consumption. Support for the Simple Tagging Plugin was dropped in favor of the WordPress 2.3 taxonomy scheme. Additional changes include some bug fixes with those combobox setting selectors in the administration interface and some code fix ups to use the WordPress API in a more consistent manner when dealing with taxonomy. Remember that this may cause PHP indigestion problems for WordPress 2.2 or earlier. The old version (1.9.x) will remain available for one month. However, version 1.9.x will no longer be supported one week after WordPress 2.3 is released.

-John Havlik

[end of transmission, stay tuned]

Breadcrumb Navigation XT Version 1.9.0

Holy GUIs, Batman! Yep, the new Breadcrumb Navigation XT administration panel/GUI is finished and distributed with the new version. Other than the administration panel, some tweaks were made involving the behavior for attachment posts (which are broken for certain permalink structures until WordPress 2.4), search pages, and date archive pages. Attachment posts are properly supported and recognized as an attachment of a post instead of a post in the ‘uncategorized’ category. Now in search pages, the search terms are output into the breadcrumb along with a customizable prefix and suffix replacing the single title of previous versions. Date archive pages when the year, month, and day are specified now allow three of the most common wording orders: big endian (ISO standard), middle endian (common in the US), and little endian (common in Europe).

The next major version 2.0.0 will contain major changes and support for WordPress 2.3. It will not be released until a WordPress 2.3 preview release has been released. 2.0.0 will nearly be rewritten from the ground up to address some performance concerns I have about the current code. These mainly pertain to unnecessary redundant branch statements that require some major work to fix. Until then, do grab Breadcrumb NavXT from its project page.

-John Havlik

[end of transmission, stay tuned]

Breadcrumb Navigation XT Version 1.8.0

Since the original author of Breadcrumb Navigation XT ran out of time for further development of the WordPress plug-in, I have picked it up. After a few days of coding and working on setting up the code section of this blog, the new version is ready for release. This new version, 1.8.0, includes support for author pages, and limiting the number of categories displayed in the breadcrumb.

Note that beginning with this release the version numbering scheme is to follow the same as WordPress uses, the first digit changes for major changes and as the second runs past 9. The second digit changes with the addition of features, internal structure of the class will not change in with a change in this digit. Finally, the third digit signifies a bugfix to features previously introduced without any added features. The next version, 1.9, is planned for the release of WordPress 2.3 due to the addition of tags into WordPress.

Check out the Breadcrumb NavXT project page to get the latest version.

-John Havlik

[end of transmission, stay tuned]

Success!

Finally RPC-heir should work as expected; it only took two weeks of frustration, and the creation of a now unneeded subdomain, plus a little extra code in the default index.php file. In this though, security is higher, as only people on weblogs.us servers can ping the RPC server, otherwise they will receive xHTML.

-John Havlik

[end of transmission, stay tuned]