Make WordPress Core

Opened 11 years ago

Closed 11 years ago

Last modified 9 days ago

#23013 closed defect (bug) (duplicate)

Gallery images don't display when original post associated with image is trashed

Reported by: nmoinvaz's profile nmoinvaz Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.5
Component: Gallery Keywords:
Focuses: Cc:

Description

I've looked through a bunch of tickets so forgive me if this is a duplicate but I couldn't find anything like it on here.

The problem I believe is that you can assign 1 image to different galleries in different posts. If you delete the original post on which the image was first attached, then the other posts with galleries that are associated with that image will no longer display the full-sized image.

I have attached a video screencast showing the problem on one of our test sites.

http://screencast.com/t/Xtft68eeeD

Repo steps:

  1. Create post A
  2. Upload image X
  3. Create gallery in post A with image X
  4. Save post A as a draft
  5. Create post B
  6. Create gallery in post B with image X
  7. Delete post A
  8. View post B
  9. Click on image X and view full-sized image

I tracked down the issue query.php around ~ line 2700 where it does a check to see if the the attachment is public/trashed. When viewing post B it instantly gets the attachment's post_parent which is now trashed.

Change History (3)

#1 @nmoinvaz
11 years ago

I am able to get around it temporarily by changing

if ( !empty($this->posts) && ($this->is_single || $this->is_page)) { 

to:

if ( !empty($this->posts) && (($this->is_single && !$this->is_attachment) || $this->is_page)) 

In query.php.

Last edited 11 years ago by nmoinvaz (previous) (diff)

#2 @helen
11 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

It's hard to tell because it only shows briefly in the screencast, but it looks like by full size image you mean the attachment page, in which case this is a duplicate of #14639

#3 @nmoinvaz
11 years ago

You are correct. This would be the same issue. Thanks for pointing me in the right direction.

Note: See TracTickets for help on using tickets.