Support » Plugin: Drafts of Post Revisions » Image transfer

  • Me again

    Currently, image attachements cannot be transferred to draft revisions but remain with the parent. When draft revisions are published, the new parent keeps the old images plus any new images added to the draft.

    I wanted to compare the parent and draft revisions image attachements so have added some code to Diff.php, please could you see if this works for you.

    cheers chap

    // setup post meta to be diffed
    private function setup_post_meta($post) {
    	$meta = get_post_custom($post->ID);
    
    	$attachments = get_posts( array(
    		'post_type' => 'attachment',
    		'posts_per_page' => -1,
    		'post_parent' => $post->ID,
    	) );
    
    	if ( $attachments ) {
    		foreach ( $attachments as $attachment ) {
    			//$class = "post-attachment mime-" . sanitize_title( $attachment->post_mime_type );
    			$thumbimg = wp_get_attachment_image_src( $attachment->ID, 'thumbnail', true );
    			//echo $output;
    			$key="Images";
    			$post->$key = $thumbimg[0];
    			$this->fields_to_add[$key] = $key;
    		}
    
    	}
    
    	foreach( $meta as $key => $value ) {
    		if ($key != '_wp_attachment_metadata') {
    			if ( in_array($key, $this->dont_include_meta) || substr($key,0,1) == '_') continue;
    			$post->$key = $value[0];
    			$this->fields_to_add[$key] = $key;
    		} else {
    			// _thumbnail_id
    			$post->$key = $value[0];
    			$this->fields_to_add[$key] = $key;
    		}
    	}
    }

    http://wordpress.org/extend/plugins/drafts-of-post-revisions/

Viewing 1 replies (of 1 total)
  • Plugin Author daxitude

    (@daxitude)

    Hey there.

    Try this on for size as a first pass:

    Diff.php

    You can drop that in place of the current Admin/Diff.php.

    Since parent attachments don’t copy over, I decided to show them symbolically on the draft. That way attachments added to the draft will show up in the comparison more clearly.

Viewing 1 replies (of 1 total)
  • The topic ‘Image transfer’ is closed to new replies.