• Stars
    star
    142
  • Rank 250,726 (Top 6 %)
  • Language
    PHP
  • License
    GNU General Publi...
  • Created about 4 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A framework for overriding the WordPress media library with an external asset provider, such as a DAM

Asset Manager Framework

This WordPress plugin provides a framework for replacing the contents of the standard WordPress media library with assets from an external provider such as a DAM, another WordPress website, or a central site within a Multisite installation.

It handles the necessary integration with WordPress (Ajax endpoints and Backbone components) leaving you to focus on just the server-side API connection to your DAM.

The intention is that the media manager, the block editor, the classic editor, the REST API, XML-RPC, and anything that calls wp.media() should "just work" and not need to implement changes in order to support a media library that is powered by an external provider.

Installation

Install with Composer:

composer require humanmade/asset-manager-framework

Status

Current status: Alpha. Generally very functional but several features still in development.

The following features work as expected:

  • Block editor: All media features
  • Classic editor: All media features
  • Media screen: All features
  • Widgets: All media widgets
  • Customizer:
    • Background Image
    • Logo (functions if you skip cropping)
    • Site Icon (unable to skip cropping of large images)
  • REST API media endpoints
  • XML-RPC requests for media
  • Any code that calls wp.media() to open the media manager and work with the selected attachments

The following custom field libraries have been tested and are compatible out of the box:

  • CMB2
  • Advanced Custom Fields (ACF)
  • Fieldmanager

The following third party plugins are supported via an included integration layer:

  • MultilingualPress 3

The following new features are planned but not yet implemented:

The following features will not be supported:

  • Side-loading media from an external media provider. The intention of this framework is that media files remain remotely hosted.
  • Built-in handling of authentication required to communicate with your external media provider. This responsibility lies within your implementation. Consider using the Keyring plugin if an OAuth connection is required.
  • Built-in support for any given media provider (such as AEM Assets, Aprimo, Bynder, or ResourceSpace). This is a framework built to be extended in order to connect it to a media provider.

Known Implementations

  • AMF WordPress for using another WordPress site, or another site on a Multisite network, as source for your media library.
  • AMF Unsplash for using Unsplash as a source.

Implementation

There are two main aspects to the plugin.

  1. Allow the media manager grid to display external items which are not existing attachments.
  2. Subsequently create a local attachment for an external item when it's selected for use.

The design decision behind this is that allowing for external items to be browsed in the media manager is quite straight forward, but unless each item is associated with a local attachment then most of the rest of WordPress breaks when you go to use an item. Previous attempts to do this have involved lying about attachment IDs, or switching to another site on a Multisite network to provide a media item. Neither approach is desirable because such lies need to be maintained and eventually you run into a situation where your lies become unravelled.

Asset Manager Framework instead allows external media items to be browsed in the media library grid, but as soon as an item is selected for use (eg. to be inserted into a post or used as a featured image), an attachment is created for the media item, and this gets returned by the media manager.

The actual media file does not get sideloaded into WordPress - it intentionally remains at its external URL. The correct external URL gets referred to as necessary, while a local object attachment is maintained that can be referenced and queried within WordPress.

Integration

There are two steps needed to integrate a media provider using the Asset Manager Framework:

  1. Create a provider which extends the AssetManagerFramework\Provider class and implements its get_id(), get_name() and request() methods to fetch results from your external media provider based on query arguments from the media manager.
  2. Hook into the amf/register_providers action to register your provider for use.

Full documentation is coming soon, but for now here's an example of a provider which supplies images from placekitten.com:

use AssetManagerFramework\{
	ProviderRegistry
	Provider,
	MediaList,
	MediaResponse,
	Image
};

class KittenProvider extends Provider {

	public function get_id() {
		return 'kittens';
	}

	public function get_name() {
		return __( 'Place Kitten' );
	}

	protected function request( array $args ) : MediaResponse {
		$kittens = [
			500 => 'Boop',
			600 => 'Fuzzy',
			700 => 'Paws',
		];
		$items = [];

		foreach ( $kittens as $id => $title ) {
			$item = new Image( $id, 'image/jpeg' );
			$item->set_url( sprintf(
				'https://placekitten.com/%1$d/%1$d',
				$id
			) );
			$item->set_title( $title );
			$item->set_width( $id );
			$item->set_height( $id );

			$items[] = $item;
		}

		return new MediaResponse(
			new MediaList( ...$items ),
			count( $kittens ), // Total number of available results.
			count( $kittens )  // Number of items requested per page.
		);
	}

}

add_action( 'amf/register_providers', function ( ProviderRegistry $provider_registry ) {
	$provider_registry->register( new KittenProvider() );
} );

Try it and your media library will be much improved:

Kittens

The MediaResponse object takes a MediaList along with the total number of available items and the number of items requested per page. This is to ensure pagination in the media library (introduced in WordPress 5.8) works.

You also have access to provider instances during registration via the amf/provider filter, so you could use it to decorate providers:

add_filter( 'amf/provider', function ( Provider $provider ) {
	if ( $provider->get_id() !== 'kittens' ) {
		return $provider;
	}

	return new DecoratingProvider( $provider );
} );

This is useful, for example, when you are using a third-party provider implementation and want to change certain behavior.

Local Media

Local media is supported by default and can be used side by side with any additional media providers but can also be controlled by using one the following methods:

  1. Defining the AMF_ALLOW_LOCAL_MEDIA constant as a boolean
  2. Use the amf/allow_local_media filter to return a boolean
  3. Use the amf/local_provider/name filter to change the Local Media label.

The filter will take precedence over the constant.

License: GPLv2

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

More Repositories

1

S3-Uploads

The WordPress Plugin to Store Uploads on Amazon S3
PHP
1,800
star
2

Custom-Meta-Boxes

Lets you easily create metaboxes with custom fields that will blow your mind.
PHP
524
star
3

Mercator

WordPress multisite domain mapping for the modern era.
PHP
505
star
4

Cavalcade

A better wp-cron. Horizontally scalable, works perfectly with multisite.
PHP
495
star
5

cf-to-tf

CLI tool for generating Terraform configuration and state for existing CloudFormation resources
JavaScript
410
star
6

WordPress-Importer

In-development rewrite of the WordPress (WXR) Importer
PHP
353
star
7

network-media-library

Network Media Library plugin for WordPress Multisite
PHP
273
star
8

Colors-Of-Image

A PHP Library for getting colors from images DEPRECATED
PHP
265
star
9

tachyon

Faster than light image resizing service that runs on AWS. Super simple to set up, highly available and very performant.
JavaScript
237
star
10

react-wp-scripts

Integrate create-react-app with your WordPress theme/plugin.
JavaScript
232
star
11

Gaussholder

Fast and lightweight image previews, using Gaussian blur
PHP
189
star
12

hm-gutenberg-tools

Useful helpers, components or tools for building things with Gutenberg
JavaScript
186
star
13

page-for-post-type

Allows you to set a page as the base URL for a post type, much like you can set a page for your blog posts.
PHP
185
star
14

aws-ses-wp-mail

An AWS SES wp_mail() drop-in
PHP
182
star
15

feelingrestful-theme

Theme for feelingrestful.com
JavaScript
176
star
16

WPThumb

⚠️ UNMAINTAINED ⚠️ On demand image resizing for WordPress
PHP
174
star
17

hm-rewrite

HM_Rewrite is a wrapper for the WordPress WP Rewrite system.
PHP
160
star
18

Restsplain

WordPress REST API documentation generator
JavaScript
152
star
19

modular-page-builder

Modular page builder for WordPress
JavaScript
149
star
20

coding-standards

Human Made coding standards for modern code
PHP
145
star
21

Salty-WordPress

A flavorful way to manage your entire WordPress stack.
SaltStack
127
star
22

publication-checklist

Run checks and enforce conditions before posts are published. Built and designed for the WordPress block editor.
JavaScript
112
star
23

hm-core

Nuclear reactor
PHP
106
star
24

Falcon

Connect WordPress to your inbox, and party like it's '88
PHP
104
star
25

wp-simple-saml

WordPress Simple SAML plugin
PHP
86
star
26

Workflows

Powerful workflows for WordPress
PHP
84
star
27

hm-base

Standard project layout for Human Made Projects.
PHP
82
star
28

roles-to-taxonomy

WordPress plugin to store user roles and levels in a taxonomy
PHP
81
star
29

repress

Connect your Redux store to the WordPress REST API.
JavaScript
81
star
30

tachyon-plugin

WordPress plugin for Tachyon
PHP
78
star
31

smart-media

Smart Media enhancements for WordPress
PHP
76
star
32

ai-plugin

An AI integration layer for WordPress
PHP
66
star
33

go-anonymize-mysqldump

Allows you to pipe data from mysqldump or an SQL file and anonymize it.
Go
60
star
34

authorship

A modern approach to author attribution in WordPress.
PHP
60
star
35

aws-rekognition

A lightweight plugin to add keywords to WordPress image uploads via automatic feature detection. Requires S3 Uploads.
PHP
56
star
36

hm-dev

Even a Poet needs tools!
PHP
55
star
37

query-monitor-flamegraph

Flamegraphs for Query Monitor
JavaScript
54
star
38

wp-remote-cli

Manage your WordPress sites using WP Remote and WP-CLI
PHP
50
star
39

wp-stripe

WordPress Plug-in to manage donations made via the Stripe credit card payment solution
PHP
50
star
40

Cavalcade-Runner

Daemon for Cavalcade, a scalable WordPress jobs system.
PHP
49
star
41

repeatable-posts

A WordPress plugin that enables the creation of repeating posts
PHP
48
star
42

altis-cms

CMS Module for Altis
PHP
47
star
43

Backdrop

Backdrop is a simple library that does one thing: allows you to run one-off tasks in the background.
PHP
47
star
44

block-editor-components

Reusable components, hooks and helper functions for the WordPress block editor(s).
JavaScript
47
star
45

clean-html

PHP
45
star
46

WordPress-Objects

Some classes for WordPress to have "real" OO objects for WordPress data types
PHP
43
star
47

react-oembed-container

React container for rendering oembed scripts within HTML string content.
JavaScript
43
star
48

Static-Page

Static Page offloading
PHP
40
star
49

react-wp-ssr

Server-side rendering for React-based WordPress plugins and themes.
PHP
38
star
50

hm-handbook-theme

HM Handbook Theme
PHP
37
star
51

orphan-command

WP-CLI command to list and delete orphan WordPress entities and metadata.
PHP
36
star
52

wp-flags

Flags: WordPress admin-controlled user-based feature flags
PHP
34
star
53

block-editor-ssr

Server Side render your interactive React Gutenberg blocks
JavaScript
34
star
54

hm-gtm

Google Tag Manager template tags and settings tool
PHP
32
star
55

trafficator

Traffic generator for local analytics testing
JavaScript
32
star
56

amf-wordpress

Use another WordPress site as source for your media library.
PHP
30
star
57

webpack-helpers

Reusable Webpack configuration components & related helper utilities.
JavaScript
29
star
58

hm-redirects

Fast and scalable redirects plugin for WordPress
PHP
28
star
59

hm-top-posts

WordPress Plugin: Top Posts by Google Analytics
PHP
28
star
60

asset-loader

PHP utilities for WordPress to aid including dynamic Webpack-generated assets in themes or plugins.
PHP
26
star
61

comment-popularity

Allow visitors to vote on comments
PHP
25
star
62

Unpublish

A plugin for unpublishing content.
PHP
25
star
63

hm-pattern-library

Juniper is the web style guide and pattern library for Human Made projects.
HTML
24
star
64

local-cognito

Local AWS Cognito test server
JavaScript
23
star
65

hm-platform

HM Hosting platform required plugins
PHP
23
star
66

altis

Altis Meta Package
22
star
67

hm-content-import

Migration framework for WordPress, attempts to reduce overhead in migrating content from differing data sources
PHP
22
star
68

wp-redis-predis-client

An alternative Redis client for use with WP Redis. Enables TLS connections.
PHP
22
star
69

hm-backup

The core backup engine that powers BackUpWordPress & WP Remote
PHP
21
star
70

plugin-tester

Simple Docker image for running unit tests for WordPress plugins
Dockerfile
21
star
71

aws-analytics

AWS Pinpoint analytics for WordPress
JavaScript
20
star
72

Mercator-GUI

A GUI component for Mercator domain mapping
PHP
19
star
73

altis-core

Core Module for Altis
PHP
19
star
74

aws-xray

HM Platform AWS X-Ray Integration
PHP
17
star
75

wp-encrypted-uploads

Upload encrypted files to WordPress, and serve them decrypted in real-time after checking user capability.
PHP
17
star
76

gutenberg-starter-kit

A plugin skeleton for creating gutenberg blocks and plugins.
JavaScript
17
star
77

rest-api-white-paper

A WordPress REST API White Paper by Human Made
16
star
78

rest-sessions

Log in and out of WordPress using the REST API.
PHP
16
star
79

memcache-object-cache

PHP
16
star
80

wp-api-demo

WP API Demo install
PHP
16
star
81

Mercator-Redirect

Redirect handler for mapped domains
PHP
15
star
82

linter-bot

Automatically run the HM Coding Standards on any repository.
JavaScript
15
star
83

job-agency

Get the workers working!
PHP
15
star
84

audit-log

Tamper resistant, off-site audit logging for WordPress
PHP
14
star
85

altis-local-server

Local Server module for Altis
PHP
14
star
86

hm-messages

A simple error / success messages API for WordPress
PHP
14
star
87

P2-By-Email

For those who like to interact with P2 by email.
PHP
14
star
88

HM-Portfolio

A WordPress Portfolio Framework Plugin, aimed at WordPress developers who don't want to duplicate the Portfolio backend.
PHP
14
star
89

Sideload-on-publish

Automatically sideload images when publishing posts/comments to ensure things don't get broken.
PHP
13
star
90

Notify-Humans

If Then, Then That for your WordPress applications.
PHP
13
star
91

hm-accounts

PHP
13
star
92

shared-media-library

WordPress plugin for a multisite shared media library - Gutenberg compatible
PHP
12
star
93

HM-Related-Posts

Related Posts (from HM Core) + Meta box for manually overriding dynamic selected posts.
PHP
12
star
94

hmn-handbook

The theme for the old handbook site. No longer used.
PHP
12
star
95

Slackbot

PHP
12
star
96

altis-enhanced-search

Enhanced Search Module for Altis
PHP
12
star
97

WordPress-Menu-Exporter

A simple plugin which enables you to only export the WordPress menus
PHP
12
star
98

MEXP-Resource-Space

WordPress Media Explorer ResourceSpace extension
PHP
11
star
99

experiments

Web Experimentation framework based on Altis Analytics
JavaScript
11
star
100

bulk-lighthouse

Run bulk lighthouse tests with pagespeed insights API.
JavaScript
11
star