Title: Attachments Plugin
Last modified: February 18, 2019

---

# Attachments Plugin

 *  Resolved [Mike Meinz](https://wordpress.org/support/users/mikemeinz/)
 * (@mikemeinz)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/attachments-plugin/)
 * I ran Media Cleaner on a test copy of my web site. I found that it marked as 
   unused all of the PDF files that had been attached to post and pages using the
   [Attachments](https://wordpress.org/plugins/attachments/) plugin.
 * Are files attached using the [Attachments](https://wordpress.org/plugins/attachments/)
   plugin supposed to be recognized and marked as used by Media Cleaner?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Jordy Meow](https://wordpress.org/support/users/tigroumeow/)
 * (@tigroumeow)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/attachments-plugin/#post-11216523)
 * Hi,
 * I didn’t know this plugin, and nobody ever told me about it before, so it’s basically
   the first time.
 * Indeed, it doesn’t seem like the kind of plugin that would be supported out of
   the box, it would need custom code to support it, so that would be part of the
   Pro version.
 * You can also find a developer to add support into it (through the custom_checkers.
   php file for instance). If you are interested in doing that, please let me know
   🙂
 *  Thread Starter [Mike Meinz](https://wordpress.org/support/users/mikemeinz/)
 * (@mikemeinz)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/attachments-plugin/#post-11219179)
 * I made the following modifications to Media Cleaner’s **scan.php** to make Media
   Cleaner handle the Attachments plugin. I hope you will consider adding this to
   the standard Media Cleaner plugin.
 * **\*\*\* Added to the end of the __construct function in scan.php:**
 *     ```
       		if ( class_exists( 'Attachments' ) )
       			add_action( 'wpmc_scan_postmeta', array( $this, 'scan_postmeta_attachments' ) );
       ```
   
 * **\*\*\* Added to the end of scan.php:**
 *     ```
       	public function scan_postmeta_attachments($id) {
       		$postmeta_images_ids=array();
       		$attachments_json=get_post_meta($id,'attachments',true);  // meta_key=='attachments'
       		$attachments_decoded=is_string($attachments_json) ? json_decode($attachments_json) : false;
       		if (!empty($attachments_decoded )) {
       			foreach ($attachments_decoded as $AttachmentData => $TheAttachment) {
       				foreach($TheAttachment as $AttachmentData => $attachment) {
       					array_push($postmeta_images_ids,$attachment->id);
       				}
       			}
       		}
       		if (!empty($postmeta_images_ids)) {
       			$this->core->add_reference_id($postmeta_images_ids, 'META (ID)' );
       		}
       	}
       ```
   
 * **\*\*\* An example of the format of the JSON string stored in the Meta_Value
   of Meta_Key==’attachments’ row for the post to which media items are attached**
 *     ```
       /*
   
       Example of Attachments plugin list of attachments to one Page/Post:
       id = Post_ID of Media Library item
       title = Title to be displayed when web page is composed.
   
       $attachments_json='{"attachments":[{"id":"27316","fields":{"title":"BOS June 20 2018 Regular Meeting Minutes"}},{"id":"27314","fields":{"title":"BOS June 20 2018 Public Hearing Minutes"}},{"id":"27302","fields":{"title":"BOS June 20 2018 Special Meeting Minutes"}},{"id":"27251","fields":{"title":"BOS June 6 2018 Regular Meeting Minutes"}},{"id":"27227","fields":{"title":"BOS June 6 2018 Public Hearing Minutes"}},{"id":"27069","fields":{"title":"BOS May 16 2018 Minutes"}},{"id":"26678","fields":{"title":"BOS April 18 2018 Minutes"}},{"id":"26608","fields":{"title":"BOS April 4 2018 Minutes"}},{"id":"26403","fields":{"title":"BOS March 7 2018 Regular Meeting Minutes"}},{"id":"26350","fields":{"title":"BOS March 7 2018 Special Budget Review Meeting"}},{"id":"26062","fields":{"title":"BOS February 21 2018 Regular Meeting Minutes"}},{"id":"26027","fields":{"title":"BOS February 21 2018 Public Hearing Minutes"}},{"id":"26002","fields":{"title":"BOS February 15 2018 Special Meeting Minutes"}},{"id":"25911","fields":{"title":"BOS February 7 2018 Minutes"}},{"id":"25812","fields":{"title":"BOS February 7 2018 Executive Session Minutes"}},{"id":"25802","fields":{"title":"BOS February 7 2018 Special Meeting Minutes"}},{"id":"25548","fields":{"title":"BOS January 17 2018 Minutes"}},{"id":"25458","fields":{"title":"BOS January 3 2018 Minutes"}}]}';
   
        */
       ```
   
    -  This reply was modified 7 years, 3 months ago by [Mike Meinz](https://wordpress.org/support/users/mikemeinz/).
 *  Plugin Author [Jordy Meow](https://wordpress.org/support/users/tigroumeow/)
 * (@tigroumeow)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/attachments-plugin/#post-11220148)
 * Hi [@mikemeinz](https://wordpress.org/support/users/mikemeinz/),
 * Of course, I will! Can you contact me directly?
    Here: [https://meowapps.com/contact](https://meowapps.com/contact)
 * I would like to share something with you to thank you 🙂

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Attachments Plugin’ is closed to new replies.

 * ![](https://ps.w.org/media-cleaner/assets/icon-256x256.png?rev=2791576)
 * [Media Cleaner: Clean your WordPress!](https://wordpress.org/plugins/media-cleaner/)
 * [Support Threads](https://wordpress.org/support/plugin/media-cleaner/)
 * [Active Topics](https://wordpress.org/support/plugin/media-cleaner/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/media-cleaner/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/media-cleaner/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Jordy Meow](https://wordpress.org/support/users/tigroumeow/)
 * Last activity: [7 years, 3 months ago](https://wordpress.org/support/topic/attachments-plugin/#post-11220148)
 * Status: resolved