humanmade / asset-manager-framework

A framework for overriding the WordPress media library with an external asset provider, such as a DAM
GNU General Public License v2.0
155 stars 7 forks source link

Gallery Support #62

Closed tomjn closed 2 years ago

tomjn commented 2 years ago

AMF doesn't currently support galleries officially ( v0.13 )

tomjn commented 2 years ago

Some notes:

tomjn commented 2 years ago

When selecting items to add to a gallery the following errors where returned by query monitor in the AJAX response:

{
    "key": "b30a06da64c986677cd88b96533a6b98",
    "type": "notice",
    "message": "Undefined index: meta",
    "file": "content/plugins/asset-manager-framework/inc/namespace.php",
    "line": 156,
    "stack": [
        "AssetManagerFramework\\ajax_select()",
        "do_action('wp_ajax_amf-select')"
    ],
    "component": "Plugin: asset-manager-framework"
}

and

{
    "key": "8bb53d2b18bdb3bfbe3420bf209b11b9",
    "type": "warning",
    "message": "Invalid argument supplied for foreach()",
    "file": "wp-includes/post.php",
    "line": 4304,
    "stack": [
        "wp_insert_post()",
        "wp_insert_attachment()",
        "AssetManagerFramework\\ajax_select()",
        "do_action('wp_ajax_amf-select')"
    ],
    "component": "Plugin: asset-manager-framework"
}
tomjn commented 2 years ago

Inserting this code eliminates all the options from the provider dropdown on the edit gallery screen:

    var MediaLibraryProviderFilter = wp.media.view.AttachmentFilters.extend({
        id: 'media-attachment-provider-filter',

        createFilters: function() {
            if ( this.options.controller._state === 'gallery-edit' ) {
                return;
            }
tomjn commented 2 years ago

This succesfully hid the dropdown on the edit gallery screen:

            if ( this.options.controller._state === 'gallery-edit' ) {
                this.$el.hide();
            } else {
                this.$el.show();
            }
tomjn commented 2 years ago

Noting that local testing of #63 results in working galleries. I'm suspicious of this as the changes are small and I expected more work to be necessary. I'd very much like independent confirmation

tomjn commented 2 years ago

Solved in #63