Monday By Noon

Attachments Pro

Price: $8.99

News: An Attachments Pro Developer License is now available!

Overview

Attachments Pro is the big brother to Attachments. With this plugin you can easily append WordPress Media items to Posts, Pages, or Custom Post Types with the end goal of integrating them within your theme with the greatest of detail.

Attachments Pro lets you add your own meta boxes to WordPress admin edit screens based on the conditions you set, with the fields you want.

WordPress has a lot of room to grow when it comes to both Media management as well as Media inclusion within your posts. Attachments Pro does what it can to fill that gap. The most frustrating thing for me as a WordPress developer was having to adhere to WordPress’ markup when it inserted an image or gallery of images. Attachments abstracts those assets and lets you use your own markup.

Adding assets via Attachments Pro uses the built in WordPress Media browser. You’re able to browse existing Media items, or add your own just as you would when adding an image to a post.

With the Media assets being managed outside the main content editor of the Post edit screen, you can now loop through each asset in your theme’s template file and output the details as you wish. There is a sample code snippet in the readme.txt that ships with Attachments Pro that walks you through adding Attachments Pro to your template files.

Features

Attachments Pro is the successor to the (always free) Attachments. Their differences are outlined below:

Feature Attachments Attachments Pro
Append media to Posts, Pages, and Custom Post Types Yes Yes
Limit meta box to certain Post Types Yes Yes
Multiple Attachments instances on edit screens No Yes
Customizable, limitless fields and labels No Yes
Ability to define rules limiting the availability of Attachments on edit screens No Yes
Limit the number of Attachments that can be added No Yes
Limit Attach-able Media items by file/mime type No Yes
Compact view on edit screens No Yes
Shortcode support No Yes
Auto-append to the_content() No Yes
Ability to use a ‘force download’ link that will download the Attachment No Yes New in 2.4.9!

Installation & Initial Setup

Once Attachments is activated, you can spend a few minutes customizing the details you’d like to set for each instance. To do so, visit the Attachments Pro link under the Settings menu in the WordPress admin. Once you have created your Attachments Pro instances, you will find the meta boxes on your Post/Page/Custom Post Type edit screens.

Code Samples

Using Attachments Pro, you can integrate your attachments using the exact markup you want. The most common way to integrate Attachments Pro is by editing your theme files and including the attachments where you’d like, how you’d like. Alternatively, you can use the auto-append feature and a custom template to achieve the same effect. The snippets below should help get you started.

Direct template integration

To integrate Attachments Pro directly with your theme, you’ll need to edit the applicable templates.

<?php
    $existing_attachments = new AttachmentsPro();

    // arguments for our first instance of Attachments
    $args   = array(
        'instance'  => 'attachments',   // the instance name
        'details'   => true             // returns more image info
    );
    // retrieve our existing Attachments for this instance
    $existing_attachments = $existing_attachments->get_attachments( $args );
?>
<?php if( !empty( $existing_attachments ) ) : ?>
    <ul>
        <?php foreach( $existing_attachments as $attachment ) : ?>
            <li>
                <pre>
                    <?php print_r( $attachment ); ?>
                </pre>
            </li>
        <?php endforeach; ?>
    </ul>
<?php endif; ?>

Shortcode filtration

There are two separate filters used by Attachments Pro. attachments_pro_format_attachments is applied to all Attachments. attachments_pro_format_attachments_{instance} is applied to only the {instance}.

function attachments_pro_custom_format_attachments( $output, $existing_attachments )
{
  ob_start();
  if( !empty( $existing_attachments ) ) : ?>
    <div class="attachments">
      <ul>
        <?php foreach( $existing_attachments as $attachment ) : ?>
          <li>
            <img src="<?php echo $attachment['src']['thumbnail']['url']; ?>" alt="<?php echo $attachment['name']; ?>" />
          </li>
        <?php endforeach; ?>
      </ul>
    </div>
  <?php endif ;
  $output = ob_get_contents();
  ob_end_clean();
  return $output;
}
// filter our Attachments Pro instance with the name 'attachments'
add_filter( 'attachments_pro_format_attachments_attachments', 'attachments_pro_custom_format_attachments', 10, 2 );

Data Returned

When working with Attachments, you’ll have an array of information available about each Attachment. That information is as follows:

Array Key Description
id ID according to WordPress’ Media library
fields Array of the instance’s fields
thumb URL to the thumbnail
name Name according to WordPress’ Media library
url Absolute URL to the original Media entry
mime File mime type according to WordPress’ Media library
filesize Array with two keys, bytes and formatted, representing the filesize of the Attachment
src Array provided (if the details argument is set to true when calling get_attachments()) of thumbnail, medium, large, and full (each a key) versions of the original Attachment. Each key consists of the following keys: url, width, height, and filesize (which is an array with the following keys: bytes and formatted).
download Link that when visited will force the download of the Attachment

Full Example

Below is a sample integrating all of the keys outlined above:

<?php
  $existing_attachments = new AttachmentsPro();

  // arguments for our first instance of Attachments
  $args   = array(
      'instance'  => 'attachments',   // the instance name
      'details'   => true,            // returns more image info
      'limit'     => 0                // limit the number of Attachments returned
    );
  // retrieve our existing Attachments for this instance
  $existing_attachments = $existing_attachments->get_attachments( $args );
?>
<?php if( !empty( $existing_attachments ) ) : ?>
  <ul>
    <?php foreach( $existing_attachments as $attachment ) : ?>
      <li>
        <h2>Name: <?php echo $attachment['name']; ?></h2>
        <p>ID: <?php echo $attachment['id']; ?></p>
        <p>URL: <?php echo $attachment['url']; ?></p>
        <p>Force Download: <?php echo $attachment['download']; ?></p>
        <p>MIME type: <?php echo $attachment['mime']; ?></p>
        <p>Filesize (bytes): <?php echo $attachment['filesize']['bytes']; ?></p>
        <p>Filesize (formatted): <?php echo $attachment['filesize']['formatted']; ?></p>
        <?php if( !empty( $attachment['fields'] ) ) : ?>
          <h5>Fields</h5>
          <ul>
            <?php foreach( $attachment['fields'] as $field ) : ?>
              <li><?php echo $field; ?></li>
            <?php endforeach; ?>
          </ul>
        <?php endif; ?>
        <?php if( !empty( $attachment['src'] ) ) : ?>
          <p>Thumbnail:
            <?php echo $attachment['src']['thumbnail']['width']; ?>px wide<br />
            <?php echo $attachment['src']['thumbnail']['height']; ?>px tall<br />
            <?php echo $attachment['src']['thumbnail']['url']; ?><br />
            <?php echo $attachment['src']['thumbnail']['filesize']['bytes']; ?> bytes<br />
            <?php echo $attachment['src']['thumbnail']['filesize']['formatted']; ?> (formatted)
          </p>
          <p>Medium:
            <?php echo $attachment['src']['medium']['width']; ?>px wide<br />
            <?php echo $attachment['src']['medium']['height']; ?>px tall<br />
            <?php echo $attachment['src']['medium']['url']; ?><br />
            <?php echo $attachment['src']['medium']['filesize']['bytes']; ?> bytes<br />
            <?php echo $attachment['src']['medium']['filesize']['formatted']; ?> (formatted)
          </p>
          <p>Large:
            <?php echo $attachment['src']['large']['width']; ?>px wide<br />
            <?php echo $attachment['src']['large']['height']; ?>px tall<br />
            <?php echo $attachment['src']['large']['url']; ?><br />
            <?php echo $attachment['src']['large']['filesize']['bytes']; ?> bytes<br />
            <?php echo $attachment['src']['large']['filesize']['formatted']; ?> (formatted)
          </p>
          <p>Full:
            <?php echo $attachment['src']['full']['width']; ?>px wide<br />
            <?php echo $attachment['src']['full']['height']; ?>px tall<br />
            <?php echo $attachment['src']['full']['url']; ?><br />
            <?php echo $attachment['src']['full']['filesize']['bytes']; ?> bytes<br />
            <?php echo $attachment['src']['full']['filesize']['formatted']; ?> (formatted)
          </p>
        <?php endif; ?>
      </li>
    <?php endforeach; ?>
  </ul>
<?php endif; ?>

Screenshots

Screenshot of Attachments Pro 2.2 Settings

Settings for a single Attachments Pro instance

An Attachments Pro instance meta box as it appears on an edit screen

Screenshot of the template reference in Attachments Pro 2.2

Auto-append template documentation

Screenshot of the new shortcode support in Attachments Pro 2.2

Shortcode insertion

Requirements

Attachments Pro requires WordPress 3.3+ and in doing so PHP5+.

Refunds

Refunds will be offered within seven days of purchase if you are unhappy with the performance of Attachments Pro and it does not meet your expectations. Refunds will not be offered as a result of malfunction due to incompatibility with another plugin or custom Theme.

Support

You can begin with the code snippet available in the readme.txt and customize using the provided details. Support is not offered in response to issues caused by other plugins or a custom theme. Before contacting support deactivate all other plugins and switch to the default WordPress Theme to determine the issue. Support is offered from 10am to 4pm ET weekdays.

Feature Requests

Feature requests are more than welcome, please use the official channel.

Purchase

Attachments Pro is currently offered at a price of $8.99 USD per domain. Please enter the appropriate destination domain name during checkout. You can use Attachments Pro in your development environment without issue, but automatic updates will be disabled until the plugin is placed in it’s live environment.

Price: $8.99

Developer License

New! Due to increased demand, a Developer License for Attachments Pro is now available! With a Developer License, you are able to install Attachments Pro on unlimited domains. The Attachments Pro Developer License is based a yearly subscription price of $49.99 USD per year. While your subscription is active, you will have access to automatic updates for unlimited installs of Attachments Pro & a Developer Forum (forthcoming) limited to Development License holders.

$49.99 per year
Powered by Fusion

Your Shopping Cart

Your cart is empty

Note: Orders are processed through PayPal via Iron to Iron, LLC

About the Store

I'm a huge fan of WordPress, and I'm involved in a number of free and open source contributions to the platform. The Store on Monday By Noon helps faciliate further contributions in those areas through the support towards development of small utility WordPress Plugins that make your life easier.

The Store is facilitated by Iron to Iron.

Loading...

My new ebook: Client Oriented WordPress Development is on sale now!