Coder Social home page Coder Social logo

masonitedoors / widen-media Goto Github PK

View Code? Open in Web Editor NEW
7.0 6.0 7.0 379 KB

Search & add Widen digital assets to your WordPress Media Library.

License: GNU General Public License v2.0

JavaScript 6.22% PHP 88.53% SCSS 5.25%
wordpress wordpress-plugin digital-asset-management cdn media-library dam

widen-media's Introduction

Widen Media

Widen Media on Packagist

Search and add Widen digital assets to your WordPress media library.

This WordPress plugin lets users search for images in Widen and add them to their site's media library. This plugin does not download media from Widen but rather creates a new WordPress media attachment that refers to the Widen asset URL. Some additional Widen metadata is captured and saved to the database on the "Add to Media Library" action. This plugin does not currently support syncing of meta data between Widen & WordPress.

Installation

You can either download a release zip and install via the WordPress plugin installer or via composer.

Composer

composer require masonitedoors/widen-media

Configuration

WordPress

This plugin uses V2 of the Widen API. You will need to define your Widen API access token in wp-config.php.

define( 'WIDEN_MEDIA_ACCESS_TOKEN', 'my-widen-api-token' );

Widen Metadata

Some additional Widen metadata is captured and saved to the database on the Add to Media Library action. This plugin does not currently support syncing of meta data between Widen & WordPress.

Collections

This plugin saves Widen collections under the post type wm_collection in order to provide a way for other themes and plugins to have access to this data without having to directly interact with Widen's API.

Within the main search page under "Add New", users can toggle "collection" when searching Widen. This will return only results that match that collection name.

When searching for a collection, a Save Collection button will be displayed. This button saves the current result page's collection to the metadata of a new post under the wp_collection post type. Note that a collection large than 100 assets will only save the 100 assets on the current results page.

Defining Custom Image Sizes

This plugin ships with some default image sizes however a filter has been included if you wish to change those defined sizes from within another plugin or theme.

Example function defining 2 image sizes:

function filter_defined_image_sizes( $default_image_sizes ) {
  $sizes = [
    'banner-sm' => [
      'label'  => __( 'Small Banner', 'textdomain' ),
      'width'  => 820,
      'height' => 312,
    ],
    'banner-lg' => [
      'label'  => __( 'Large Banner', 'textdomain' ),
      'width'  => 1500,
      'height' => 500,
    ],
  ];

  // Uncomment to append sizes to the plugin's already defined sizes.
  // $sizes = array_merge( $sizes, $default_image_sizes );

  return $sizes;
}
add_filter( 'wm_defined_image_sizes', 'filter_defined_image_sizes', 10, 1 );

Plugin API

This plugin provides some function to allow other plugins to easly interact with Widen data imported into WordPress as well as the Widen API.

wm_get_collections()

Returns an array of collection objects.

wm_get_collection( int $collection_id )

Returns the collection object.

wm_get_asset_fields( int $asset_id )

Returns all the fields from Widen for an asset that exists within the WordPress Media Library.

wm_get_asset_field( int $asset_id, string $key, bool $single = false )

Returns a single field for a Widen asset that exists within the WordPress Media Library.

widen-media's People

Contributors

alexgarrisonmercury avatar dependabot[bot] avatar jdashley27 avatar josephfusco avatar mwks-jg avatar sagarrison12 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

widen-media's Issues

Add pagination to bottom of search results.

#3 added helpful pagination to the search results. Pagination added to the bottom of the page would be amazing so that a user doesn't have to scroll all the way back up to the top of the results each time.

Allow user to sync meta data from Widen

Currently once an asset is added there is no way to automatically update the asset's metadata within WordPress with any changes from Widen.

This should be a button somewhere within wp-admin to initiate this action

We can also create a widen-media WP-CLI command to allow for metadata syncs programatically.

Cannot add a new page to a menu when plugin is active

In the menu screen of wp-admin, when this plugin is active, a 500 error can be seen when attempting to add a new page to a menu.

<br><b>Uncaught Error</b>: Cannot use object of type WP_Error as array in <b>/opt/masonite-wp/var/www/html/wordpress/wp-content/plugins/widen-media/lib/Admin.php</b> on line <b>974</b><br><ul><li>save_post_collection_cb()<br><span class=“qm-info qm-supplemental”>wp-includes/class-wp-hook.php:289</span></li><li>apply_filters()<br><span class=“qm-info qm-supplemental”>wp-includes/class-wp-hook.php:311</span></li><li>do_action()<br><span class=“qm-info qm-supplemental”>wp-includes/plugin.php:478</span></li><li>do_action()<br><span class=“qm-info qm-supplemental”>wp-includes/post.php:4153</span></li><li>wp_insert_post()<br><span class=“qm-info qm-supplemental”>wp-includes/nav-menu.php:521</span></li><li>wp_update_nav_menu_item()<br><span class=“qm-info qm-supplemental”>wp-admin/includes/nav-menu.php:961</span></li><li>wp_save_nav_menu_items()<br><span class=“qm-info qm-supplemental”>wp-admin/includes/ajax-actions.php:1491</span></li><li>wp_ajax_add_menu_item()<br><span class=“qm-info qm-supplemental”>wp-includes/class-wp-hook.php:287</span></li><li>apply_filters()<br><span class=“qm-info qm-supplemental”>wp-includes/class-wp-hook.php:311</span></li><li>do_action()<br><span class=“qm-info qm-supplemental”>wp-includes/plugin.php:478</span></li><li>do_action()<br><span class=“qm-info qm-supplemental”>wp-admin/admin-ajax.php:175</span></li></ul><p>There has been a critical error on your website.</p><p><a href=“https://wordpress.org/support/article/debugging-in-wordpress/”>Learn more about debugging in WordPress.</a></p>

Add pagination to search results

We need pagination within the search results as it currently caps out at 100 (the request limit).

Total amount of results for that search should also be displayed.

Add filter for search

A great feature for this would be to filter what a based on file type or category of files to see. An example of this would be to display only images or only documents. Also, filters could be added for showing only .pdf or .png. This would rely on #21 for the document support before it would be feasible.

Support Document File Types

It would be great for the plugin to be able to support document file types (e.g. .pdf, .docx .txt) and allow for them to be uploaded to Wordpress from Widen.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.