function Resource::rich

Same name in other branches
  1. 8.9.x core/modules/media/src/OEmbed/Resource.php \Drupal\media\OEmbed\Resource::rich()
  2. 10 core/modules/media/src/OEmbed/Resource.php \Drupal\media\OEmbed\Resource::rich()
  3. 11.x core/modules/media/src/OEmbed/Resource.php \Drupal\media\OEmbed\Resource::rich()

Creates a rich resource.

Parameters

string $html: The HTML representation of the resource.

int $width: The width of the resource, in pixels.

int $height: (optional) The height of the resource, in pixels.

\Drupal\media\OEmbed\Provider $provider: (optional) The resource provider.

string $title: (optional) A text title, describing the resource.

string $author_name: (optional) The name of the author/owner of the resource.

string $author_url: (optional) A URL for the author/owner of the resource.

int $cache_age: (optional) The suggested cache lifetime for this resource, in seconds.

string $thumbnail_url: (optional) A URL to a thumbnail image representing the resource. If this parameter is present, $thumbnail_width and $thumbnail_height must also be present.

int $thumbnail_width: (optional) The width of the thumbnail, in pixels. If this parameter is present, $thumbnail_url and $thumbnail_height must also be present.

int $thumbnail_height: (optional) The height of the thumbnail, in pixels. If this parameter is present, $thumbnail_url and $thumbnail_width must also be present.

Return value

static

4 calls to Resource::rich()
OEmbedIframeControllerTest::testResourcePassedToPreprocess in core/modules/media/tests/src/Kernel/OEmbedIframeControllerTest.php
Tests that resources can be used in media_oembed_iframe preprocess.
OEmbedSourceTest::testThumbnailUri in core/modules/media/tests/src/Kernel/OEmbedSourceTest.php
Tests that remote thumbnails are downloaded correctly.
Resource::video in core/modules/media/src/OEmbed/Resource.php
Creates a video resource.
ResourceFetcher::createResource in core/modules/media/src/OEmbed/ResourceFetcher.php
Creates a Resource object from raw resource data.

File

core/modules/media/src/OEmbed/Resource.php, line 307

Class

Resource
Value object representing an oEmbed resource.

Namespace

Drupal\media\OEmbed

Code

public static function rich($html, $width, $height = NULL, Provider $provider = NULL, $title = NULL, $author_name = NULL, $author_url = NULL, $cache_age = NULL, $thumbnail_url = NULL, $thumbnail_width = NULL, $thumbnail_height = NULL) {
    if (empty($html)) {
        throw new \InvalidArgumentException('The resource must provide an HTML representation.');
    }
    $resource = new static($provider, $title, $author_name, $author_url, $cache_age, $thumbnail_url, $thumbnail_width, $thumbnail_height);
    $resource->type = self::TYPE_RICH;
    $resource->html = $html;
    $resource->setDimensions($width, $height);
    return $resource;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.