Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 314044

Media library potentially triggers remote oEmbed request for each media item

$
0
0

Problem/Motivation

The following three circumstances don't play together well:

  1. OEmbed::getMetadata() fetches the oEmbed resource regardless of the metadata attribute being fetched. If the resource data is not cached (because, for example, the entire cache was just cleared) this means an actual HTTP request is performed against the resource URL
  2. Media adds a theme suggestion containing the oEmbed provider name to list of suggestions for rendered media. This allows, for example, styling YouTube and Vimeo thumbnails differently, even though they belong to the same bundle (Remote video). To do this Media needs to call OEmbed::getMetadata()
  3. The media library may contain up to 24 rendered media items

Steps to reproduce

Put together, if the most recent 24 media items on your site are YouTube videos and you visit the media library immediately after a cache clear, Drupal will perform 24 oEmbed requests to YouTube in order to determine that each of these videos is, in fact, from YouTube. That's not ideal.

Proposed resolution

There are different possible solutions to this:

  1. Do nothing, and accept that this can happen
  2. Remove the theme suggestion based on the provider name
  3. Change the theme suggestion logic to only add the provider name if the provider name field is mapped to a field and then use the field value to create the suggestion
  4. Make OEmbed::getMetadata() not fetch the oEmbed resource when just returning provider info (in particular, for the provider_name and provider_url attributes). Instead call UrlResolver::getProviderByUrl() for those two attribute names. Note that there is a potential performance regression interms of HTTP requests here, in case the resource URL and the resource data are both in the cache but the provider list is not.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet


Viewing all articles
Browse latest Browse all 314044

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>