• Resolved Mike Meinz

    (@mikemeinz)


    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 plugin.

    Are files attached using the 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

    (@tigroumeow)

    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

    (@mikemeinz)

    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, 1 month ago by Mike Meinz.
    Plugin Author Jordy Meow

    (@tigroumeow)

    Hi @mikemeinz,

    Of course, I will! Can you contact me directly?
    Here: 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.