[wp-trac] [WordPress Trac] #41445: post_parent can prevent media from embedding correctly

WordPress Trac noreply at wordpress.org
Fri Dec 17 16:46:14 UTC 2021

#41445: post_parent can prevent media from embedding correctly
 Reporter:  loboyle                              |       Owner:
                                                 |  adamsilverstein
     Type:  defect (bug)                         |      Status:  assigned
 Priority:  normal                               |   Milestone:  6.0
Component:  Media                                |     Version:  4.9.4
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch needs-testing dev-         |     Focuses:  rest-api
  feedback needs-unit-tests                      |
Changes (by adamsilverstein):

 * milestone:  Future Release => 6.0


 Hey @orhanc thanks for the ping, apologies for letting this ticket
 linger... I had overlooked this 'future release' ticket and it is probably
 too late to land this change for 5.9, so I will tag it for 6.0.

 Although the code in [attachment:"41445.3.diff"] works in testing, it is
 not quite ready to land...

 First, @TimothyBlynJacobs raised an important point in
 this comment] - calling `get_post_status` can add an additional meta query
 (specifically when the parent is in the trash) so it might be worth
 considering what Timothy suggested:

 > whenever a post is moved to a non-public status, check if it is the
 parent of any media items. If so, looks for a new parent candidate by
 doing the _thumbnail_id meta query?

 So that would be another post that had used the image as featured?

 Also from @galbaras -
 > Conversely, if a deleted post is reinstated, its embedded images should
 be re-attached to it.

 That would be good to support if possible, especially since it is the
 current behavior. The exception would be the case where the image has
 already been attached to a different post (which isn't possible now).

 In addition, this change needs some backing unit tests to validate the
 expected behavior.

Ticket URL: <https://core.trac.wordpress.org/ticket/41445#comment:40>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list