Enclosures in WordPress

This is test post. There’s an enclosure attached to this post so take a look at my rss2 feed to find it!

Add the URL of the enclosed media file by pasting it into the “Enclosures” text field. WordPress will figure out how big the file is, and the type of file automatically and save that data in a custom field. You can edit that data later through the usual custom field interface.
Because a remote server has to be contacted, it may take longer than usual to save posts with enclosures! This is normal, so wait until the page has completed loading!

Read more on enclosures to find out why they’re useful.

Currently, you have to add the enclosure in the “Enclosures” text field in the following format:
url_length_type or as an example: http://blogs.linux.ie/download/referers.gif_126007_image/gif

Thanks Matt for pointing out I had a problem with the “Host” line of my code – I left out the “:”

As an exercise I created an “enclosure” custom field handler. It returns the details of the custom field in an array which I print using the following Smarty code in post.html under the call to {custom_fields}:

{if $enclosure != ''}
<blockquote><b>Attached Enclosure</b><br />
File: <a href="{$enclosure.0}">{$enclosure.0}</a><br />
Length: {$enclosure.1} bytes<br />
Type: {$enclosure.2}<br /></blockquote>
{assign var='enclosure' value=''} <!-- reset enclosure variable again! -->

7 thoughts on “Enclosures in WordPress

  1. Pingback: Bernard Flach .com

Leave a Reply

%d bloggers like this:

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.