• Resolved nsitu

    (@nsitu)


    When I click “Insert into Post” it only works partly: a link to the file is properly embedded, but the file does NOT become attached to the post (or visible in the Gallery tab). The problem only exists for items already in the Media Library. In the context of a NEW upload, there is no problem.

    Can someone give me pointers in tracing this issue? Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Check your uploads path in Settings -> Media. Sounds like it’s been changed.

    Thread Starter nsitu

    (@nsitu)

    Upload path is ‘wp-content/uploads’

    Try removing the path and leaving the uploads path blank.

    Thread Starter nsitu

    (@nsitu)

    Okay, good suggestion. I just tried it, and it makes no difference. I don’t think it’s a problem with the path, but rather the attachment. I want the file to show up in the Gallery tab once it’s inserted, and that’s not happening right now.

    Thread Starter nsitu

    (@nsitu)

    I decided to compare with another fresh WordPress install. The fresh copy does not have this issue.

    I discovered that the media library, when functioning properly, lists a hidden field with each item like this:
    <input type="hidden" name="attachments[10][post_parent]" id="attachments[10][post_parent]" value="163">

    This field is, for some reason, missing on the broken install.

    I also discovered that WordPress renders this hidden field in /wp-admin/includes/media.php, around line 1404:

    foreach ( $hidden_fields as $name => $value )
    		$item .= "\t<input type='hidden' name='$name' id='$name' value='" . esc_attr( $value ) . "' />\n";
    
    	if ( $post->post_parent < 1 && isset( $_REQUEST['post_id'] ) ) {
    		$parent = (int) $_REQUEST['post_id'];
    		$parent_name = "attachments[$attachment_id][post_parent]";
    		$item .= "\t<input type='hidden' name='$parent_name' id='$parent_name' value='$parent' />\n";
    	}
    
    	return $item;

    Still not sure where to go with this, though. Thanks for any further ideas.

    Thread Starter nsitu

    (@nsitu)

    Okay, my bad: it looks like this behavior is by design. A file can only be attached to one post at a time. So, clicking “Insert into Post”, does not guarantee that a file will necessarily attach. If it’s already attached somewhere else, the existing attachment will hold.

    It makes me wonder if there’s an easier way to manage attachments. Is there some plugin that adds an “Attach To” button when editing media?

    Not that I’m aware of. As you’ve said, a file can only be attached to one post at a time. But you could upload a fresh copy of the file to the second/new post.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘"Insert into Post" embeds link but fails to create attachment’ is closed to new replies.