Right now, media_internet_get_provider() checks every provider to find the appropriate one for the given embed string. In some cases, it would be helpful to limit the providers it checks. One example use case would be limiting the available providers in field instance settings. In my case I'm writing a contrib module with a construct similar to field instances where this ability to filter providers would be helpful.

I've written a small patch that introduces this feature and preserves backwards compatibility. I'll upload it in a couple minutes.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

chasingmaxwell’s picture

Here's the patch. I believe it can be applied to both the 7.x-2.x and 7.x-1.x branches without modification.

Devin Carlson’s picture

Status: Active » Needs review
Chris Matthews’s picture

Status: Needs review » Closed (won't fix)
Issue tags: +Needs reroll

The 5 year old patch in #1 to media_internet.module does not apply to the latest media 7.x-2.x-dev, but feel free to submit a re-rolled patch
and a media maintainer will consider re-opening if you need this and want it reviewed.

Checking patch modules/media_internet/media_internet.module...
error: while searching for:
 * Finds the appropriate provider for a given URL or embed_string
 *
 * Each provider has a claim() method which it uses to tell media_internet
 * that it should handle this input.  We cycle through all providers to find
 * the right one.
 *
 * @todo: Make this into a normal hook or something because we have to instantiate
 * each class to test and that's not right.
 */
function media_internet_get_provider($embed_string) {
  foreach (media_internet_get_providers() as $class_name => $nothing) {
    $p = new $class_name($embed_string);
    if ($p->claim($embed_string)) {
      return $p;

error: patch failed: modules/media_internet/media_internet.module:99
error: modules/media_internet/media_internet.module: patch does not apply
Chris Matthews’s picture

Status: Closed (won't fix) » Needs work
Chris Matthews’s picture

Status: Needs work » Closed (outdated)

Per joseph.olstad, closing as outdated.