Make WordPress Core

Opened 14 years ago

Closed 14 years ago

#18912 closed defect (bug) (fixed)

No "insert into post" from Media Library

Reported by: anmari's profile anmari Owned by: azaozz's profile azaozz
Milestone: 3.3 Priority: normal
Severity: normal Version: 3.3
Component: Media Keywords: reporter-feedback dev-feedback has-patch
Focuses: Cc:

Description

IN firefox and chrome, when adding media to a post, the "insert into post" button appears for

'from computer' and 'from url'

but does not appear when selecting image 'from Media Library'.

Attachments (6)

noinsertintopost.png (68.2 KB) - added by anmari 14 years ago.
Screenshot of add media - media library - show media - no "insert into post
page1.png (50.9 KB) - added by anmari 14 years ago.
screenshot - some images have insert post, others not
page2.png (71.8 KB) - added by anmari 14 years ago.
screenshot - some images have insert post, others not
page3.png (53.0 KB) - added by anmari 14 years ago.
screenshot 3 - some images have insert post, others not
18912.patch (801 bytes) - added by SergeyBiryukov 14 years ago.
18912.2.patch (922 bytes) - added by SergeyBiryukov 14 years ago.

Download all attachments as: .zip

Change History (15)

@anmari
14 years ago

Screenshot of add media - media library - show media - no "insert into post

#1 @duck_
14 years ago

  • Keywords reporter-feedback added

I cannot reproduce this in either Firefox or Chromium. Could you try disabling all plugins and reverting to the default theme?

@anmari
14 years ago

screenshot - some images have insert post, others not

@anmari
14 years ago

screenshot - some images have insert post, others not

@anmari
14 years ago

screenshot 3 - some images have insert post, others not

#2 @anmari
14 years ago

ok - twenty ten theme, no plugins (no dropins!) -wp beta about a day or so old.

It seems to happen to some images but not all. It is not positional (at first I though the first image worked).

I cannot see any pattern as yet, it is a mix of old/new images, mix of sizes, some where the image isn't actually there will actually have 'insert post' and others will not. (see attached).

Possibly something to do with image names being same/similar, but cannot see that happening consistently

I can see it also on a remote test site where I let other people login. If anyone feels like seeing the problem they can loginat test.icalevents.com with atester/test and edit a draft, and try to add from media library Images with names like 'projecto_contentores' . (not a wp beta site, at latest wp, does have plugins)

See also attached shots.

Very weird.

Last edited 14 years ago by anmari (previous) (diff)

#3 follow-up: @SergeyBiryukov
14 years ago

The button only appears if the attachment parent post supports editor:
http://core.trac.wordpress.org/browser/tags/3.2.1/wp-admin/includes/media.php#L1209

From what I see in the Media Library screen on test.icalevents.com, some images are attached to posts which don't have an edit link and are nowhere to be found among Posts or Events (e.g. "Arte Publica Contemporânea – Projecto Contentores – CCB", "The Magic Flute by W.A. Mozart").

There's probably some inconsistency in the database or your custom post types registration code.

#4 @anmari
14 years ago

Hi Sergey,

Thanks for looking at it, however
1) this is also happening on a local test site with standard posts.
2) the custom post types on that site do support editor - more likely the original custom post was deleted.

Also it would appear therefore, that a media item cannot be 're-used' in certain circumstances?

eg: if maybe unattached to anything (post deleted?) or maybe as you suggest originally added (how? if no editor support) to a post that does not have editor support.

I'll try spend some time later to see if I can recreate the condition but from what you have said it sounds to me like there is some sort of logic flaw.

No matter what an image or media item is originally attached to (or no longer attached to), surely one should be able to re-use it ?

#5 in reply to: ↑ 3 ; follow-up: @SergeyBiryukov
14 years ago

  • Keywords dev-feedback has-patch added

Replying to SergeyBiryukov:

The button only appears if the attachment parent post supports editor

Correction: the button also appears for unattached images, due to true at the end of the expression.

If the parent post was moved to Trash, the button is still displayed. If the parent post was deleted permanently, the image becomes unattached, and the button is also still displayed.

So the only condition for the button not to appear is when the image is attached to a post, and that post type doesn't support editor (or something makes WP think so).

That said, it doesn't make much sense to me. If we're going to insert the image into *current* post, I guess we should check if *that* post type supports editor, not the *original* attachment parent post.

The patch seems to revert [14146], so needs feedback. Not sure if dd32's comment about missing $_GET['post_id'] is still relevant.

Related: #12792, #14133

#6 in reply to: ↑ 5 ; follow-up: @azaozz
14 years ago

Replying to SergeyBiryukov:

...
So the only condition for the button not to appear is when the image is attached to a post, and that post type doesn't support editor (or something makes WP think so).

That said, it doesn't make much sense to me.

Right. Seems we will have to improve the logic there. Whether an image can be inserted should depend on the supported features of the current post, not the attachment parent.

If $post_id is not present in some cases perhaps it would be better to assume the current post supports editor (most common). Perhaps we can try always passing $post_id as we have a "real" post ID now from the very beginning.

#7 in reply to: ↑ 6 @SergeyBiryukov
14 years ago

Replying to azaozz:

If $post_id is not present in some cases perhaps it would be better to assume the current post supports editor (most common).

Thanks, done in 18912.2.patch.

#8 @nacin
14 years ago

  • Milestone changed from Awaiting Review to 3.3

Pretty sure this code changed in 3.3, so moving to 3.3.

#9 @azaozz
14 years ago

  • Owner set to azaozz
  • Resolution set to fixed
  • Status changed from new to closed

In [19350]:

Show Insert into post button in the media library when the current post supports editor (not the attachment parent), props SergeyBiryukov, fixes #18912

Note: See TracTickets for help on using tickets.