[resolved] attachments.js, thickbox iframe within a thickbox iframe (3 posts)

  1. bmellor
    Posted 3 years ago #

    I have a peculiar application whereby my post edit screen is presented in a thickbox window, instead of being the top.document.

    When I click the "Attach" button located in the Attachments metabox on the post edit screen, that brings up the "Attach a file" thickbox containing the media-upload interface, within the thickbox that is already existing and holding my post edit screen.

    So now I have a top.document, a first thickbox containing the post edit screen, and a second thickbox (within the first thickbox) containing the media-upload interface.

    The trouble arises in that the attachments plugin javascript is not expecting to find the post edit screen in a parent thickbox iframe. It's expecting to find it only as the top.document, I believe.

    Clicking "attach" in the media-upload interface pops up the "Attached!" message, but the attachment is not actually showing up in the Attachments metabox on the post edit screen, which exists as an upper level iframe instead of all the way at top.document.

    I replaced all top.document references in attachments.js with parent.document but that did not fix the problem. I'm looking at theparent=jQuery(this).parent().parent().parent() and thinking the trouble may be in there someone, but the js here is a little over my head.


  2. Jonathan Christopher
    Plugin Author

    Posted 3 years ago #

    This issue is outside the scope of the plugin as it's meant to be used in a standard WordPress admin.

  3. bmellor
    Posted 3 years ago #

    Stating that issue is outside the scope of the plugin is not actually a "resolution." I'm not sure what is referred to by a "standard WordPress admin." I am not able to find this reference in the documentation.

    If readers are interested in an actual resolution, it can be had by adding something to the effect of attach_list = Query(document).find('#attachments_list'); as the first line of the attachments_handle_attach function, and then replacing the four references to top.document that appear in the attachments_handle_attach function with the variable attach_list that you just created.

    In this manner, the script will successfully locate the attachments wherever they might appear within the DOM, and not blindly assume that they are in top.document.

    The entire attachments.js from version 1.6.1 of the attachments plugin is reproduced here with the suggested changes. It has been reformatted with an emphasis on comprehensibility.

    [162 lines of code moderated as per the Forum Rules. The maximum number of lines of code that you can post in these forums is ten lines. Please use the pastebin]

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Attachments
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic