Opened 12 years ago
Closed 2 years ago
#23041 closed defect (bug) (maybelater)
Images Don't Become Attached When Inserting a Gallery
Reported by: | miqrogroove | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.5 |
Component: | Gallery | Keywords: | has-patch |
Focuses: | Cc: |
Description
Steps to Reproduce:
- Go to the "Upload New Media" page (wp-admin/media-new.php)
- Upload an image.
- Create a new post.
- Create an image gallery that includes the newly-uploaded image.
- Insert the gallery into the post.
- Publish the post.
Expected result: Any "(Unattached)" image(s) should get attached.
Actual result: Images remain "(Unattached)".
Attachments (1)
Change History (41)
#1
@
12 years ago
- Component changed from Media to Gallery
- Milestone changed from Awaiting Review to 3.5.1
#2
follow-up:
↓ 3
@
12 years ago
... use case: Gallery outside of the_content() section of a post., design wise post data on left, gallery in a column on the right, impossible (as far as I know ;/) to do unless images are attached to the gallery of the post.
This is how I was doing it post 3.5, which no longer works (works with previous pre 3.5 attached images though).
$columns = get_post_meta( $post->ID, 'comic-gallery-columns', true ); if (empty($columns)) $columns = 5; $args = array( 'id' => $post->ID, 'columns' => $columns, 'exclude' => $post_image_id ); $output .= gallery_shortcode($args);
Now that the images are unattached another way to do this now would be to make another custom meta field to contain the ID's that represent the gallery and store them that way
Just a thought.. didn't exactly want to install a overbearing gallery plugin and waste all that processing when I could be using internal core code.
#3
in reply to:
↑ 2
;
follow-up:
↓ 9
@
12 years ago
Replying to Frumph:
... use case: Gallery outside of the_content() section of a post., design wise post data on left, gallery in a column on the right, impossible (as far as I know ;/) to do unless images are attached to the gallery of the post.
My question is, why are the images unattached to begin with? If they are uploaded to the post, they'll be "attached" automatically. That's all you need to do in 3.5, and that's all you could do in 3.4. So I'm curious what workflow worked in 3.4 that no longer works in 3.5. The process was so strict in 3.4 (the images needed to be uploaded to the post) that nothing should have broken.
#4
follow-up:
↓ 5
@
12 years ago
.. Ah, workflow
Creating new post. Create a Gallery. Select which images to use for the gallery. Only options are to "cancel and go back" or "insert into post". Both of those do not attach those images to the gallery (as I would expect), one just enters the shortcode into the post and the other one apparently just cancels what you just did.
Previous version of WordPress retained what images were assigned to the gallery for that post, this one doesn't, or is not. NEW images are attaching themselves to the post yes. But unable to select older images and have it retained.
.. also can't sort order the images added to the post either now - guess those are based off the ids="" string that gets added to the shortcode put into the post.
#5
in reply to:
↑ 4
@
12 years ago
Replying to Frumph:
Previous version of WordPress retained what images were assigned to the gallery for that post, this one doesn't, or is not. NEW images are attaching themselves to the post yes. But unable to select older images and have it retained.
That doesn't seem accurate. Before 3.5 there was no gallery option at all in that situation. You had to attach the images first.
#6
@
12 years ago
Right, you loaded up the add media button (used to be a * at some point) then you clicked on the media library portion and selected it etc, which added it to the gallery page with the others. (don't remember if they were ones labelled unattached or they were attached to another post at the time)
#7
@
12 years ago
Maybe there needs to be a discussion about going back to showing only attached images on the gallery tab as the default filter. Let authors "insert" anything from the Library tab as an IMG, but restrict what goes into a gallery by default, to save the confusion.
#9
in reply to:
↑ 3
@
12 years ago
Replying to nacin:
My question is, why are the images unattached to begin with? So I'm curious what workflow worked in 3.4 that no longer works in 3.5.
I think it's something that works in 3.5, that did not work before: You can add images to a gallery, that were not uploaded to the post.
While attaching on insert works for previously unattached images, it won't scale for images that are part of multiple galleries, since attachements can only have one parent. See #22960.
#10
follow-up:
↓ 11
@
12 years ago
My apology in advance if I mistaken something, but I think this ticket is invalid and is confusing.
"Image don't become attached when inserting a gallery"
This is normal and expected.
The way gallery(shortcode) works now (WP3.5) doesn't care if the images assign to what posts, it just take the ids and pull them up, this doesn't need images to be able to be attached to multiple parents.
Why do we need to make images in a gallery (WP3.5+) become attached to any post that appears to be using images pulled from other post ?
At least for me, an image should have only 1 parent, because there is no reason for otherwise.
#11
in reply to:
↑ 10
;
follow-up:
↓ 13
@
12 years ago
- Cc trivum added
Why do we need to make images in a gallery (WP3.5+) become attached to any post that appears to be using images pulled from other post ?
I think it's important because, for one, it lets you insert galleries into template files and then update those galleries via the Media Manager. Suppose you had a gallery inserted in multiple spots in your template files. You would need to go back into each template and update the galleries by hand.
The same goes for posts. You could make a gallery and then insert that gallery into multiple posts (let's say 10 different posts). If you wanted to update that gallery the way it is now, you would need to update each of the 10 different posts by hand. If the images were attached to the original gallery, you could just update that one gallery and the rest would be updated automatically. You could also update that gallery with the visual Media Manager (and not the less user-friendly hand-edited shortcode).
I came across this issue when trying to use a gallery id in a shortcode. I outlined it here:
It seems that in 3.5 when you try to insert a gallery into a template file with the gallery id, it no longer works.
Previously, for example, this would work:
<?php echo do_shortcode('[gallery id="123"]'); ?>
Now, however, because the shortcode has been changed to list out the individual images, referring to the gallery as a whole doesn't work anymore.
The advantage of still having a reference to the entire gallery and not individual images in this case is that you can go in and edit the gallery in the visual editor without digging back into the template code. Just update the gallery as you like, and it's updated everywhere you inserted that gallery in your template files.
Does anyone know if this is just a glitch, or is this how it will be going forward?
According to this page (which seems to have been updated for 3.5 -- at least partly), referring to the entire gallery should still work.
#12
follow-up:
↓ 14
@
12 years ago
To the recent commenters: This ticket is not for attaching an image to multiple posts. Could you please take that debate to a new ticket?
#13
in reply to:
↑ 11
@
12 years ago
Replying to trivum:
Why do we need to make images in a gallery (WP3.5+) become attached to any post that appears to be using images pulled from other post ?
I think it's important because, for one, it lets you insert galleries into template files and then update those galleries via the Media Manager.
Please take a look here
http://core.trac.wordpress.org/browser/tags/3.5/wp-includes/media.php#L671
The id
attribute, along with include
, exclude
, are still there in WP3.5
If it doesn't work, there must be a bug or something else going on.
Whatever it is, I can't see it has anything to do with this ticket. #22960 is what you need.
#14
in reply to:
↑ 12
;
follow-up:
↓ 15
@
12 years ago
Replying to miqrogroove:
Expected result: Any "(Unattached)" image(s) should get attached.
This ticket is asking for the ability to have multiple parents (for an image), if this is not the case, then please close this ticket and focus on #22960 instead.
#15
in reply to:
↑ 14
@
12 years ago
Replying to paulwp:
Replying to miqrogroove:
Expected result: Any "(Unattached)" image(s) should get attached.
This ticket is asking for the ability to have multiple parents (for an image)
No, it's not. It's saying that, on gallery creation, any images that currently do not have a parent should be assigned one. Images with an existing parent would be untouched.
#16
follow-up:
↓ 17
@
12 years ago
Before WP3.5 there is "insert into post" that automatically assign the unattached image to become attached to whatever post (or page) that it is being inserted to.
This ability is still there in WP3.5 ( I just tested, it works).
Upload an image via Media so that it's unattached, once uploaded see the "Attached to" column (in WP3.5 the text changed to "Uploaded to") it is now saying "(unattached)" with the clickable link underneath saying "Attach" that invites you to attach it to any post of your choice, now keep this page open, then make a new post and click "Add Media" select images then click "insert into post" now go back to refresh the Media Library page, you will see it now become attached to that post.
The ability to attach the unattached image has been there and is still there. Users upload images directly thru the Media Library so that it is not attached and they can decide (with intention) to attach them later thru "insert into post" or thru Media Library page.
Let's not forget this is a ticket for WP3.5 onward. There is no need to add this ability into gallery, it will defeat the purpose of having multiple galleries regardless of its parents.
#17
in reply to:
↑ 16
;
follow-up:
↓ 18
@
12 years ago
Replying to paulwp:
Let's not forget this is a ticket for WP3.5 onward. There is no need to add this ability into gallery, it will defeat the purpose of having multiple galleries regardless of its parents.
Honestly, the way this new Media UI is designed, I don't think most users can tell the difference between an attachment and a gallery. Or for that matter, the difference between uploading to Add Media vs. uploading to Upload New Media. The differences are confusing.
There is a problem for users who still expect a relationship between images and posts. If images are showing up in a post but don't have the correct parent/child permalinks or paging links or post parent API then that is a regression from 3.4. Inserting a gallery should not leave images totally orphaned.
#18
in reply to:
↑ 17
@
12 years ago
Replying to miqrogroove:
Honestly, the way this new Media UI is designed, I don't think most users can tell the difference between an attachment and a gallery. Or for that matter, the difference between uploading to Add Media vs. uploading to Upload New Media. The differences are confusing.
Yes Sir, ditto, we all have been thru that.
There is a problem for users who still expect a relationship between images and posts. If images are showing up in a post but don't have the correct parent/child permalinks or paging links or post parent API then that is a regression from 3.4
I believe this #23044 will fix it, it's marked for 3.6 though.
Inserting a gallery should not leave images totally orphaned.
Inserting (placing) image as a single or several img tag(s) OR having a WP's gallery in the post doesn't necessary mean that you want those images attached to that post.
#19
follow-up:
↓ 20
@
12 years ago
I personally see attachment in WP the same way it is in email's attachment.
If you upload file thru a post (or an email) then it's attached to that particular post (or email) because it's your intention to do so, but if you upload it thru skydrive(hotmail) or gdrive(gmail) then it's unattached by intention, usage is done by pasting links.
If the above makes sense…
then we should remove the ability to auto attach the unattached when "insert into post" (and do not add this ability to gallery). Also, the "insert into post" should be renamed to "paste into post" or "place into post" because that's what it actually is.
Users upload images directly via Media Library because they want them unattached and if decide later, the attach business can be done directly via Media Library as well. (this is doable then and still doable now - even in bulk)
#20
in reply to:
↑ 19
@
12 years ago
Yeah, I have to disagree. I don't believe in creating a "right" place and a "wrong" place to upload images. It would confuse the hell out of me.
#21
@
12 years ago
23041.diff changes "create gallery" and "add to gallery" tabs to use the settings for "uploaded to this post" in their default libraries.
#22
@
12 years ago
I think I am +1 on 23041.diff for 3.5.1. We can sidestep the enhancement (attach unattached images when adding them to a gallery) and attempt a slight correction in the user workflow.
#24
follow-up:
↓ 25
@
12 years ago
Say you have no images attached to this post and you go create a gallery, with "Uploaded to this post" being the default. It would give you an upload window. I am not sure if that is expected behavior, or weird behavior. Probably both. Closest to expected would be to only use "Uploaded to this post" as the default if there were already such images.
#25
in reply to:
↑ 24
@
12 years ago
Replying to nacin:
Say you have no images attached to this post and you go create a gallery, with "Uploaded to this post" being the default. It would give you an upload window. I am not sure if that is expected behavior, or weird behavior. Probably both. Closest to expected would be to only use "Uploaded to this post" as the default if there were already such images.
Which is not easy to do and seems to indicate that it is time to punt.
#27
@
12 years ago
- Cc jond3r@… added
My two cents: I think it is valuable to be able to view a gallery one image at a time using the attachment page, and navigating using next_ and previous_image_link(), which in its current implementation requires the same post parent on all images.
Hopefully this can be solved reliably later via #22960, #23044 and others.
In the meantime the original proposal in this ticket would offer an improvement. I was thinking along two ways of solving this. Either via a new AJAX call when the gallery is inserted or possibly better (and simpler?) when the post is updated, by parsing the content for gallery ids. The latter way could be implemented as a plugin, if desired.
Setting "Uploaded to this post" as default as in attachment:23041.diff is better than nothing. Even better would be a possibility to disable the (All) "Images" option (by a theme/plugin), which is really the option that causes all trouble. - But this would exclude unattached images, which is not ideal, so these should be possible to include in some way, which is probably not easy to come up with at this time...
#32
follow-up:
↓ 33
@
11 years ago
Let's see if I can articulate what I am thinking is erm, not necessarily wrong, but method of utilization.
As you know I create comic sites for people; recently made comic easel which is a plugin that uses the media library. When people upload comics to their custom post type it's attached as a featured image. Previous to the 3.? whatever, attachments were associated to the post via the post ID, so I could let people who wanted multiple comics per day attach them into the gallery and they would attach to the post id. So I would search for all of the attachments on that post ID and then loop display them, there is multiple images for that post.
Now however, I can still do that; unfortunately the media UI doesn't show all of the images that are attached to the current post, it shows them all. So the end user cannot see the images that they attached to the post and modify the gallery for that post since .. really there isn't a way to do it anymore. Once the media library changed; that UI functionality is gone. The 'core' backend function is still there though; so the attached-to-the-post-images still get displayed; just no way to work it with the UI.
#33
in reply to:
↑ 32
@
11 years ago
Replying to Frumph:
unfortunately the media UI doesn't show all of the images that are attached to the current post, it shows them all.
It does, just select "Uploaded to this post" in the dropdown filter.
#34
@
11 years ago
Holy $#!+ there it is! Going to have to write up good documentation for my end users on that one; that's not easily found.
#35
@
11 years ago
- Milestone changed from 3.6 to Future Release
Six months and I haven't seen much in the way of clamoring for 23041.diff, nor particularly loud or numerous complaints. At this point, it's possibly a degraded behavior change (or, certainly, a change in what people may have gotten used to after 3.5) — and needs user testing. Time to punt.
This ticket was mentioned in Slack in #core-flow by boren. View the logs.
9 years ago
#40
@
6 years ago
- Keywords bulk-reopened added
This is still a problem with Wordpress 5.1. Can this ticket be updated to reflect that? Unfortunately I don't see versions later than 3.5 in this tickets drop down menu.
#41
@
6 years ago
@dajuan It was reported against 3.5 and reopened. If it is still a problem then the ticket is correct.
#42
@
2 years ago
- Keywords bulk-reopened removed
- Resolution set to maybelater
- Status changed from new to closed
I came across this one going through the list of tickets missing a milestone.
I did some testing with the most recent version of WordPress (currently 6.0) and this is the current behavior related to unattached images:
Classic Editor active:
- Inserting an unattached image assigns the post as the attachment's parent.
- Inserting unattached images into a gallery does not change the parent of the attachments.
- Uploading an attachment to a post does assign the post as it's parent.
Block Editor (no Classic Editor plugin)
- Inserting unattached image does not set the post as the attachment's parent.
- Inserting unattached images into a gallery does not change the parent of the attachments.
- Uploading an attachment to a post does assign the post as it's parent.
I'm going to close this out as a maybelater
. Since the block editor is not changing the post_parent
for unattached images when inserting into an image block, this issue within galleries (when using the Classic Editor) and gallery blocks makes the behavior consistent.
Tickets do not need to be open for conversation to continue. If someone feels that the behavior of setting an attachment's post_parent
to the current post when inserting an unattached should be restored, the same can be added for galleries, and there will likely need to be an accompanying ticket in the Gutenberg GitHub repository.
When inserting an image into a post, we attach any unattached images. Not entirely convinced of the need at this point, but it seems sane to do the same for a gallery.