Wordpress Plugin
Download latest - 3.5.9



Download Stats

Today 28
Yesterday 61
Last Week 293
All Time 219,542
Banner 772x250

Extensive usage instructions are available on GitHub

Attachments allows you to simply append any number of items from your WordPress Media Library to Posts, Pages, and Custom Post Types.

Extend Attachments with add-ons

This plugin does not directly interact with your theme, you will need to edit your template files. If you prefer working with a UI, take a look at Attachments UI

Associate Media items with posts

The idea behind Attachments is to give developers the ability to directly associate Media items with any post. This is accomplished by adding a meta box to post edit screens as determined by the developer. Once Media items have been associated with a post, you're able to retrieve those Attachments and include them directly within your template files using any specific markup you wish.

Integrate Attachments within your theme with fine grained control

Attachments does not automatically integrate itself with your theme. Since the idea behind Attachments is to allow integration of Media within posts using developer-crafted, unique markup, it's up to you to integrate with your theme. The most basic integration includes editing the appropriate template file and adding your call(s) to Attachments. For example, if you have set up Attachments to be used with your Posts entries, edit single.php to include the following within The Loop:

<?php $attachments = new Attachments( 'attachments' ); /* pass the instance name */ ?> <?php if( $attachments->exist() ) : ?> <h3>Attachments</h3> <p>Total Attachments: <?php echo $attachments->total(); ?></p> <ul> <?php while( $attachments->get() ) : ?> <li> ID: <?php echo $attachments->id(); ?><br /> Type: <?php echo $attachments->type(); ?><br /> Subtype: <?php echo $attachments->subtype(); ?><br /> URL: <?php echo $attachments->url(); ?><br /> Image: <?php echo $attachments->image( 'thumbnail' ); ?><br /> Source: <?php echo $attachments->src( 'full' ); ?><br /> Size: <?php echo $attachments->filesize(); ?><br /> Title Field: <?php echo $attachments->field( 'title' ); ?><br /> Caption Field: <?php echo $attachments->field( 'caption' ); ?> </li> <?php endwhile; ?> </ul> <?php endif; ?>

That snippet will request all of the existing Attachments defined for the current Post within The Loop, and retrieve each itemized property for that Attachment. Using the provided details you're able to integrate the attached Media items in any way you please.

There is a lot more information on Attachments' GitHub page. Please contribute!

Releases (61 )

Version Release Date Change Log
3.5.9 2017-10-11
  • Added link to collapse Attachments to make sorting easier
  • Fixes PHP Notice on installation
  • Fixes illegal offset error on PHP7
  • Added Dutch translation
3.5.7 2015-07-06
  • Fixed a regression that prevented attaching multiple files at once
3.5.6 2015-07-02
  • Fixed an issue where changing an Attachment on more than one Attachment would continually update the first Attachment
  • Media modal now includes filters (props marcochiesi)
  • Added German translation (props bessl)
  • Added filter to manipulate Attachments metadata before it's saved: attachments_meta_before_save
  • Underscores are no longer enforced over hyphens
  • More entropy for Attachments uid's to prevent collisions (props sketchpad)
3.5.5 2015-04-21
  • Fixed an issue where field values were improperly overwritten when the instance was set to prepend in some cases
3.5.4 2014-04-09
  • Fixed assumption of field keys (props bukka)
  • Improved documentation (props Lane Goldberg, Roman Kokarev, Ore Landau)
  • Added rewind() method to reset Attachments reference array (props joost de keijzer)
  • TinyMCE fix to support WordPress 3.9+
  • Fixed an issue where nonce was potentially wrongly flagged as sent if an instance was filtered
  • Added post_parent argument support for instances, setting to true will populate the Uploaded to column in Media
  • New filter: attachments_default_instance to disable/enable the default instance (default is true, ATTACHMENTS_DEFAULT_INSTANCE constant is deprecated)
  • New filter: attachments_settings_screen to hide/show the settings screen (default is true, ATTACHMENTS_SETTINGS_SCREEN constant is deprecated)
  • Fixed an issue where Attachments meta box(es) would not show up when creating new posts whose post_type had a dash in it
  • Updated Italian translation (props Luca Speranza)
3.5.3 2013-10-25
  • Cleaned up PHP Warning/Notice (props Mike C.)
  • Fixed a potential fatal error triggered by deleting something from the Media library that was an Attachment
  • Tested with WordPress 3.7
3.5.2 2013-09-27
  • Fixed an issue where newline characters may not be properly retrieved
  • Fixed an issue with localization not initializing properly
  • Resolved a PHP Strict warning (props @bukka) 2013-05-20
  • Fixed an issue where Featured Images may have become inadvertently disabled, props @deborre
3.5.1 2013-05-20
  • Fixed an issue where changing an Attachment changed all attachments, props @bartoszwww
  • Fixed an issue where certain Unicode characters weren't decoded properly, props @stuk88
3.5 2013-05-13
  • Initial implementation of limiting the number of Attachments
  • You can now change an Attachment asset without having to remove the entire Attachment and re-add something new
  • New filter: attachments_location_{my_instance} (where **{my_instance}** is your instance name) allows for more fine-grained control over where meta boxes show up (e.g. limiting to your Home page)
  • New action: attachments_extension facilitates Attachments extensions
  • New method width( $size ) to retrieve the width of the current Attachment
  • New method height( $size ) to retrieve the height of the current Attachment
  • New document structure, various additions to documentation
  • Attachments Pro migration script. If you've been waiting to migrate from Attachments Pro please back up your database and run the migration script.
  • Fixed an asset URL issue if Attachments is added as a must-use plugin
  • Italian translation (props Marco Chiesi) 2013-04-05

= 3.0 = Now piggybacking the awesome Media workflow introduced in WordPress 3.5

3.4.2 2013-04-05

= 3.0 = Now piggybacking the awesome Media workflow introduced in WordPress 3.5

3.4 2013-03-07

= 3.0 = Now piggybacking the awesome Media workflow introduced in WordPress 3.5

3.3.3 2013-02-05
  • Fixed a PHP Warning when activated using Multisite
  • Slightly modified the migration process to better handle plugins like WPML (props sebastian.friedrich)
3.3.2 2013-01-25
  • You can now specify which view is default when browsing the Media modal (e.g. have 'Upload Files' be default instead of 'Media Library')
3.3.1 2013-01-18
  • Added meta box positioning arguments when registering instances
  • Cleaned up some CSS when Attachments instances are in the sidebar
3.3 2013-01-18
  • Added a search() method to allow searching for Attachments based on their attributes (e.g. attachment ID, post ID, post type, field values, etc.)
  • Improved the 'Remove' animation
  • New field: select
  • New parameter for Attachments attributes methods. You can pass the index (int) of the Attachment you'd like to utilize when firing the method.
3.2 2013-01-17
  • Added option to disable the Settings screen
  • Added the ability to set a default for fields using the metadata that exists in WordPress. Available defaults include: title, caption, alt, and description. If set, the metadata for the correlating field will be used as the field default when initially adding an Attachment from the Media modal. Only applies to text, textarea, and wysiwyg fields.
  • Added a get_single() method that allows you to specifically retrieve a single Attachment
  • Clarified some documentation
3.1.4 2013-01-09
  • Changed 'Delete' to 'Remove' so as to not make it sound like the file itself would be deleted from Media (props Lane Goldberg)
  • Better handling of posts that have no Attachments when saving
3.1.3 2013-01-05
  • Fixed a potential issue with the WYSIWYG field not working on CPT without editor support
  • Field assets are less aggressive and only fire when necessary
  • Reorganized the migration process a bit in prep for Attachments Pro support
3.1.2 2013-01-04
  • Fixed a regression that prevented successful migration of legacy Attachments data
3.1.1 2013-01-04
  • Fixed a Fatal Error when registering the text field
3.1 2013-01-04
  • New field: wysiwyg
  • Fields will now properly respect line breaks
  • Fields will now properly return HTML instead of escaped HTML 2012-12-23

= 3.0 = You will need to update your theme files that use Attachments 3.0. Version 1.x of Attachments has been fully deprecated but is still available. If you would like to continue to use the (no longer supported) 1.x version you may add the following to your wp-config.php:

define( 'ATTACHMENTS_LEGACY', true ); // force the legacy version of Attachments

Version 3 is a major rewrite. While I've taken precautions in ensuring you won't lose any saved data it is important to back up your databse prior to upgrading in case something goes wrong. This version is a complete rewrite so all legacy data will be left in place, but a migration must take place to match the new data storage model and workflow.

= 1.0.8 = As always, be sure to back up your database and files before upgrading.

= 1.0.7 = Attachments are now stored in such a way that removes an in-place limitation on string lengths for both titles and captions. 2012-12-22
  • Better storage of special characters for PHP 5.4+
3.0.8 2012-12-22
  • Fixed an issue in Firefox where you weren't able to focus inputs unless you clicked their label
  • New field: textarea
3.0.7 2012-12-21
  • Proper sanitization of Custom Post Type names (as WordPress does it)
3.0.6 2012-12-21
  • Fixed a possible JavaScript error if an Attachment that's an image doesn't have a proper thumbnail URL
  • Added a total() method that will return the number of Attachments for the current instance
  • When requesting the image() for a non-image Attachment, the WordPress-defined icon will be returned
  • Added an icon() method that will return the WordPress-defined icon for the Attachment
  • Cleaned up a PHP Warning when trying to save for an undefined field type
  • Fixed an issue where template tags would be output for non-image Attachments after saving 2012-07-18
  • Fixed an issue with Handlebars in Firefox
  • Better handling of Attachment name
1.6.2 2012-07-17
  • Fixed an issue when you both add and delete Attachments prior to saving posts
  • Cleaned up the JavaScript that powers the file browse interaction
  • Swapped out some custom code for WordPress native function calls
  • Better handling of asset inclusion
1.6.1 2012-01-22
  • Fixed a conflict with WP-Ecommerce
1.6 2011-12-13
  • Updated settings to use the Settings API
  • Tested with WordPress 3.3
  • Removed support for extremely legacy Attachments storage. If you have upgraded from a version before 1.0.7, please downgrade to 1.5.10 and let me know.
1.5.10 2011-11-14
  • WordPress 3.3 compatibility
  • Updated Polish translation
  • Removed soon-to-be deprecated jQuery methods in prep for 1.7
1.5.9 2011-09-29
  • Retrieve file size when firing attachments_get_attachments()
1.5.8 2011-09-05
  • Code cleanup
1.5.7 2011-08-28
  • Translation update
1.5.6 2011-08-14
  • Better restriction of JavaScript assets as a preventative measure for potential plugin conflicts
1.5.5 2011-08-14

Re-implemented bulk Attach

1.5.4 2011-08-13
  • Updated the way Thickbox is hijacked in an effort to be more stable among tab switching. As an unfortunate result, bulk attaching is no longer possible.
  • Added environment check in preparation for future feature updates
  • Updated Polish translation, courtesy of Wiktor Maj 2011-06-06

= 1.0.8 = As always, be sure to back up your database and files before upgrading.

= 1.0.7 = Attachments are now stored in such a way that removes an in-place limitation on string lengths for both titles and captions. 2011-06-04
  • PHP warning cleanup
  • Settings now respect Custom Post Types that are set to show_ui
1.5.3 2011-06-03
  • Added Polish translation, courtesy of Wiktor Maj
  • Added Posts and Pages to Settings
  • Added new setting to natively 'Attach' Attachments via $post->post_parent
1.5.2 2011-02-28
  • Added Swedish translation, courtesy of Sebastian Johansson
  • 'Attach' button is now localized
  • Fixed a couple of other miscellaneous localization issues
  • Added Italian translation, courtesy of Andrea Bersi
  • Fixed a number of PHP notices/warnings in more strict environments 2010-12-06
  • Fixed bug with handling legacy Attachments data store
  • Updated localization hook for options screen 2010-10-25
  • Fixed JS var naming error in IE
  • Hid NextGen tab in browser
1.5.1 2010-10-13
  • Fixed thumbnail rendering issue
  • Fixed issue where browse modal included extraneous items after filtering or searching
1.5 2010-10-11
  • Completely revamped the upload/browse experience. Attachments now uses WordPress default modal dialogs.
1.1.1 2010-09-21
  • Fixed a bug with storing foreign characters
  • Added live search to Browse Existing Dialog
1.1 2010-09-03
  • Fixed a bug where Attachments meta box would display on Custom Post Types even when set not to
  • Fixed a bug where special characters were lost on save
  • Fixed a bug where Browse/Add buttons failed to work when an Editor was not available on a Custom Post Type
1.0.9 2010-08-08
  • Support for Custom Post Types (found in Settings)
  • Revised Portuguese Translation by Miriam de Paula
1.0.8 2010-07-02
  • Fixed possible bug with images not thumbnailing properly
  • Tabbed media browsing implemented 2010-03-21
  • Added Portuguese Translation (rough)
1.0.7 2010-03-08
  • Numerous fixes to enhance data integrity
  • Implemented a change to improve data portability
  • Moved to Thickbox (from Shadowbox) as to be more in line with WordPress
1.0.5 2010-01-02
  • Added the option to limit available Attachments to the current user (defaults to false) 2009-12-08 2009-12-07
  • Removed all shortcodes in an effort to boost compatibility
1.0.4 2009-11-27
  • Fixed a potential error resulting in PHP issuing a Warning when trying to attach Attachments
1.0.3 2009-11-04
  • Fixed an issue when attachments_get_attachments() returning no Attachments generating a warning
1.0.2 2009-11-02
  • Fixed an issue with deleting Attachments
1.0.1 2009-11-02
  • Fixed an error when adding only one attachment
  • Added MIME type array value (mime) to available attachments
1.0 2009-11-02
  • First stable release