Commit 27f8cd4c authored by alexpott's avatar alexpott

Issue #2027423 by claudiu.cristea, tim.plunkett, andypost: Make image style system flexible.

parent 176fbe7c
......@@ -608,7 +608,7 @@ function theme_image_style_effects($variables) {
*
* @param $variables
* An associative array containing:
* - style: The image style array being previewed.
* - style: \Drupal\image\ImageStyleInterface image style being previewed.
*
* @ingroup themeable
*/
......@@ -634,9 +634,9 @@ function theme_image_style_preview($variables) {
$original_attributes['style'] = 'width: ' . $original_width . 'px; height: ' . $original_height . 'px;';
// Set up preview file information.
$preview_file = image_style_path($style->id(), $original_path);
$preview_file = $style->buildUri($original_path);
if (!file_exists($preview_file)) {
image_style_create_derivative($style, $original_path, $preview_file);
$style->createDerivative($original_path, $preview_file);
}
$preview_image = image_get_info($preview_file);
if ($preview_image['width'] > $preview_image['height']) {
......
......@@ -74,8 +74,8 @@ function hook_image_effect_info_alter(&$effects) {
* be cleared using this hook. This hook is called whenever a style is updated,
* deleted, or any effect associated with the style is update or deleted.
*
* @param Drupal\image\Plugin\Core\Entity\ImageStyle $style
* The image style array that is being flushed.
* @param \Drupal\image\ImageStyleInterface $style
* The image style object that is being flushed.
*/
function hook_image_style_flush($style) {
// Empty cached data that contains information about the style.
......
This diff is collapsed.
......@@ -2,7 +2,7 @@
/**
* @file
* Contains \Drupal\image\Plugin\Core\Entity\ImageStyleInterface.
* Contains \Drupal\image\ImageStyleInterface.
*/
namespace Drupal\image;
......@@ -14,4 +14,99 @@
*/
interface ImageStyleInterface extends ConfigEntityInterface {
/**
* Delivers an image derivative.
*
* Transfers a generated image derivative to the requesting agent. Modules may
* implement this method to set different serve different image derivatives
* from different stream wrappers or to customize different permissions on
* each image style.
*
* @param string $scheme
* The scheme name of the original image file stream wrapper ('public',
* 'private', 'temporary', etc.).
* @param string $target
* The target part of the uri.
*
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse|\Symfony\Component\HttpFoundation\Response
* The image to be delivered.
*
* @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
* \Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException
*
* @todo Move to controller after https://drupal.org/node/1987712.
*/
public function deliver($scheme, $target);
/**
* Returns the URI of this image when using this style.
*
* The path returned by this function may not exist. The default generation
* method only creates images when they are requested by a user's browser.
* Modules may implement this method to decide where to place derivatives.
*
* @param string $uri
* The URI or path to the original image.
*
* @return string
* The URI to the image derivative for this style.
*/
public function buildUri($uri);
/**
* Returns the URL of this image derivative for an original image path or URI.
*
* @param string $path
* The path or URI to the original image.
* @param mixed $clean_urls
* (optional) Whether clean URLs are in use.
*
* @return string
* The absolute URL where a style image can be downloaded, suitable for use
* in an <img> tag. Requesting the URL will cause the image to be created.
*
* @see \Drupal\image\ImageStyleInterface::deliver()
*/
public function buildUrl($path, $clean_urls = NULL);
/**
* Flushes cached media for this style.
*
* @param string $path
* (optional) The original image path or URI. If it's supplied, only this
* image derivative will be flushed.
*/
public function flush($path = NULL);
/**
* Creates a new image derivative based on this image style.
*
* Generates an image derivative applying all image effects and saving the
* resulting image.
*
* @param string $original_uri
* Original image file URI.
* @param string $derivative_uri
* Derivative image file URI.
*
* @return bool
* TRUE if an image derivative was generated, or FALSE if the image
* derivative could not be generated.
*/
public function createDerivative($original_uri, $derivative_uri);
/**
* Determines the dimensions of this image style.
*
* Stores the dimensions of this image style into $dimensions associative
* array. Implementations have to provide at least values to next keys:
* - width: Integer with the derivative image width.
* - height: Integer with the derivative image height.
*
* @param array $dimensions
* Associative array passed by reference. Implementations have to store the
* resulting width and height, in pixels.
*/
public function transformDimensions(array &$dimensions);
}
......@@ -39,8 +39,9 @@ function testNormal() {
// Create derivative image.
$styles = entity_load_multiple('image_style');
$style = image_style_load(key($styles));
$derivative_uri = image_style_path($style->id(), $file->getFileUri());
image_style_create_derivative($style, $file->getFileUri(), $derivative_uri);
$original_uri = $file->getFileUri();
$derivative_uri = $style->buildUri($original_uri);
$style->createDerivative($original_uri, $derivative_uri);
// Check if derivative image exists.
$this->assertTrue(file_exists($derivative_uri), 'Make sure derivative image is generated successfully.');
......
......@@ -7,7 +7,7 @@
namespace Drupal\image\Tests;
use Drupal\Core\Language\Language;
use Drupal\image\ImageStyleInterface;
/**
* Tests creation, deletion, and editing of image styles and effects.
......@@ -25,7 +25,7 @@ public static function getInfo() {
/**
* Given an image style, generate an image.
*/
function createSampleImage($style) {
function createSampleImage(ImageStyleInterface $style) {
static $file_path;
// First, we need to make sure we have an image in our testing
......@@ -36,13 +36,13 @@ function createSampleImage($style) {
$file_path = file_unmanaged_copy($file->uri);
}
return image_style_url($style->id(), $file_path) ? $file_path : FALSE;
return $style->buildUrl($file_path) ? $file_path : FALSE;
}
/**
* Count the number of images currently create for a style.
*/
function getImageCount($style) {
function getImageCount(ImageStyleInterface $style) {
return count(file_scan_directory('public://styles/' . $style->id(), '/.*/'));
}
......@@ -271,9 +271,13 @@ function testStyleReplacement() {
$nid = $this->uploadNodeImage($test_image, $field_name, 'article');
$node = node_load($nid);
// Get node field original image URI.
$fid = $node->get($field_name)->target_id;
$original_uri = file_load($fid)->getFileUri();
// Test that image is displayed using newly created style.
$this->drupalGet('node/' . $nid);
$this->assertRaw(image_style_url($style_name, file_load($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['target_id'])->getFileUri()), format_string('Image displayed using style @style.', array('@style' => $style_name)));
$this->assertRaw($style->buildUrl($original_uri), format_string('Image displayed using style @style.', array('@style' => $style_name)));
// Rename the style and make sure the image field is updated.
$new_style_name = strtolower($this->randomName(10));
......@@ -285,7 +289,10 @@ function testStyleReplacement() {
$this->drupalPost($style_path . $style_name, $edit, t('Update style'));
$this->assertText(t('Changes to the style have been saved.'), format_string('Style %name was renamed to %new_name.', array('%name' => $style_name, '%new_name' => $new_style_name)));
$this->drupalGet('node/' . $nid);
$this->assertRaw(image_style_url($new_style_name, file_load($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['target_id'])->getFileUri()), 'Image displayed using style replacement style.');
// Reload the image style using the new name.
$style = entity_load('image_style', $new_style_name);
$this->assertRaw($style->buildUrl($original_uri), 'Image displayed using style replacement style.');
// Delete the style and choose a replacement style.
$edit = array(
......@@ -295,8 +302,9 @@ function testStyleReplacement() {
$message = t('Style %name was deleted.', array('%name' => $new_style_label));
$this->assertRaw($message);
$replacement_style = entity_load('image_style', 'thumbnail');
$this->drupalGet('node/' . $nid);
$this->assertRaw(image_style_url('thumbnail', file_load($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['target_id'])->getFileUri()), 'Image displayed using style replacement style.');
$this->assertRaw($replacement_style->buildUrl($original_uri), 'Image displayed using style replacement style.');
}
/**
......@@ -360,9 +368,13 @@ function testConfigImport() {
$nid = $this->uploadNodeImage($test_image, $field_name, 'article');
$node = node_load($nid);
// Get node field original image URI.
$fid = $node->get($field_name)->target_id;
$original_uri = file_load($fid)->getFileUri();
// Test that image is displayed using newly created style.
$this->drupalGet('node/' . $nid);
$this->assertRaw(image_style_url($style_name, file_load($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['target_id'])->getFileUri()), format_string('Image displayed using style @style.', array('@style' => $style_name)));
$this->assertRaw($style->buildUrl($original_uri), format_string('Image displayed using style @style.', array('@style' => $style_name)));
// Copy config to staging, and delete the image style.
$staging = $this->container->get('config.storage.staging');
......@@ -374,4 +386,5 @@ function testConfigImport() {
$this->assertFalse(entity_load('image_style', $style_name), 'Style deleted after config import.');
$this->assertEqual($this->getImageCount($style), 0, 'Image style was flushed after being deleted by config import.');
}
}
......@@ -44,7 +44,7 @@ function testImageDimensions() {
$style = entity_create('image_style', array('name' => 'test', 'label' => 'Test'));
$style->save();
$generated_uri = 'public://styles/test/public/'. drupal_basename($original_uri);
$url = image_style_url('test', $original_uri);
$url = $style->buildUrl($original_uri);
$variables = array(
'style_name' => 'test',
......
......@@ -112,7 +112,7 @@ function _testImageFieldFormatters($scheme) {
// Ensure the derivative image is generated so we do not have to deal with
// image style callback paths.
$this->drupalGet(image_style_url('thumbnail', $image_uri));
$this->drupalGet(entity_load('image_style', 'thumbnail')->buildUrl($image_uri));
$image_info['uri'] = $image_uri;
$image_info['width'] = 100;
$image_info['height'] = 50;
......@@ -124,7 +124,7 @@ function _testImageFieldFormatters($scheme) {
if ($scheme == 'private') {
// Log out and try to access the file.
$this->drupalLogout();
$this->drupalGet(image_style_url('thumbnail', $image_uri));
$this->drupalGet(entity_load('image_style', 'thumbnail')->buildUrl($image_uri));
$this->assertResponse('403', 'Access denied to image style thumbnail as anonymous user.');
}
}
......
......@@ -15,11 +15,11 @@
*
* image.effects.inc:
* image_style_generate()
* image_style_create_derivative()
* \Drupal\image\ImageStyleInterface::createDerivative()
*
* image.module:
* image_style_options()
* image_style_flush()
* \Drupal\image\ImageStyleInterface::flush()
* image_effect_definition_load()
* image_effect_load()
* image_effect_save()
......
......@@ -34,8 +34,8 @@ function createSampleImage($style, $wrapper) {
// Make sure we have an image in our wrapper testing file directory.
$source_uri = file_unmanaged_copy($file->uri, $wrapper . '://');
// Build the derivative image.
$derivative_uri = image_style_path($style->id(), $source_uri);
$derivative = image_style_create_derivative($style, $source_uri, $derivative_uri);
$derivative_uri = $style->buildUri($source_uri);
$derivative = $style->createDerivative($source_uri, $derivative_uri);
return $derivative ? $derivative_uri : FALSE;
}
......
......@@ -22,9 +22,10 @@ class ImageStylesPathAndUrlTest extends WebTestBase {
*/
public static $modules = array('image', 'image_module_test');
protected $style_name;
protected $image_info;
protected $image_filepath;
/**
* @var \Drupal\image\ImageStyleInterface
*/
protected $style;
public static function getInfo() {
return array(
......@@ -37,58 +38,57 @@ public static function getInfo() {
function setUp() {
parent::setUp();
$this->style_name = 'style_foo';
$style = entity_create('image_style', array('name' => $this->style_name, 'label' => $this->randomString()));
$style->save();
$this->style = entity_create('image_style', array('name' => 'style_foo', 'label' => $this->randomString()));
$this->style->save();
}
/**
* Test image_style_path().
* Tests \Drupal\image\ImageStyleInterface::buildUri().
*/
function testImageStylePath() {
$scheme = 'public';
$actual = image_style_path($this->style_name, "$scheme://foo/bar.gif");
$expected = "$scheme://styles/" . $this->style_name . "/$scheme/foo/bar.gif";
$actual = $this->style->buildUri("$scheme://foo/bar.gif");
$expected = "$scheme://styles/" . $this->style->id() . "/$scheme/foo/bar.gif";
$this->assertEqual($actual, $expected, 'Got the path for a file URI.');
$actual = image_style_path($this->style_name, 'foo/bar.gif');
$expected = "$scheme://styles/" . $this->style_name . "/$scheme/foo/bar.gif";
$actual = $this->style->buildUri('foo/bar.gif');
$expected = "$scheme://styles/" . $this->style->id() . "/$scheme/foo/bar.gif";
$this->assertEqual($actual, $expected, 'Got the path for a relative file path.');
}
/**
* Test image_style_url() with a file using the "public://" scheme.
* Tests an image style URL using the "public://" scheme.
*/
function testImageStyleUrlAndPathPublic() {
$this->_testImageStyleUrlAndPath('public');
$this->doImageStyleUrlAndPathTests('public');
}
/**
* Test image_style_url() with a file using the "private://" scheme.
* Tests an image style URL using the "private://" scheme.
*/
function testImageStyleUrlAndPathPrivate() {
$this->_testImageStyleUrlAndPath('private');
$this->doImageStyleUrlAndPathTests('private');
}
/**
* Test image_style_url() with the "public://" scheme and unclean URLs.
* Tests an image style URL with the "public://" scheme and unclean URLs.
*/
function testImageStylUrlAndPathPublicUnclean() {
$this->_testImageStyleUrlAndPath('public', FALSE);
function testImageStyleUrlAndPathPublicUnclean() {
$this->doImageStyleUrlAndPathTests('public', FALSE);
}
/**
* Test image_style_url() with the "private://" schema and unclean URLs.
* Tests an image style URL with the "private://" schema and unclean URLs.
*/
function testImageStyleUrlAndPathPrivateUnclean() {
$this->_testImageStyleUrlAndPath('private', FALSE);
$this->doImageStyleUrlAndPathTests('private', FALSE);
}
/**
* Tests image_style_url() with a file URL that has an extra slash in it.
* Tests an image style URL with a file URL that has an extra slash in it.
*/
function testImageStyleUrlExtraSlash() {
$this->_testImageStyleUrlAndPath('public', TRUE, TRUE);
$this->doImageStyleUrlAndPathTests('public', TRUE, TRUE);
}
/**
......@@ -96,30 +96,29 @@ function testImageStyleUrlExtraSlash() {
*/
function testImageStyleUrlForMissingSourceImage() {
$non_existent_uri = 'public://foo.png';
$generated_url = image_style_url($this->style_name, $non_existent_uri);
$generated_url = $this->style->buildUrl($non_existent_uri);
$this->drupalGet($generated_url);
$this->assertResponse(404, 'Accessing an image style URL with a source image that does not exist provides a 404 error response.');
}
/**
* Tests image_style_url().
* Tests building an image style URL.
*/
function _testImageStyleUrlAndPath($scheme, $clean_url = TRUE, $extra_slash = FALSE) {
$request = $this->prepareRequestForGenerator($clean_url);
function doImageStyleUrlAndPathTests($scheme, $clean_url = TRUE, $extra_slash = FALSE) {
$this->prepareRequestForGenerator($clean_url);
// Make the default scheme neither "public" nor "private" to verify the
// functions work for other than the default scheme.
config('system.file')->set('default_scheme', 'temporary')->save();
// Create the directories for the styles.
$directory = $scheme . '://styles/' . $this->style_name;
$directory = $scheme . '://styles/' . $this->style->id();
$status = file_prepare_directory($directory, FILE_CREATE_DIRECTORY);
$this->assertNotIdentical(FALSE, $status, 'Created the directory for the generated images for the test style.');
// Create a working copy of the file.
$files = $this->drupalGetTestFiles('image');
$file = array_shift($files);
$image_info = image_get_info($file->uri);
$original_uri = file_unmanaged_copy($file->uri, $scheme . '://', FILE_EXISTS_RENAME);
// Let the image_module_test module know about this file, so it can claim
// ownership in hook_file_download().
......@@ -127,9 +126,9 @@ function _testImageStyleUrlAndPath($scheme, $clean_url = TRUE, $extra_slash = FA
$this->assertNotIdentical(FALSE, $original_uri, 'Created the generated image file.');
// Get the URL of a file that has not been generated and try to create it.
$generated_uri = image_style_path($this->style_name, $original_uri);
$generated_uri = $this->style->buildUri($original_uri);
$this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.');
$generate_url = image_style_url($this->style_name, $original_uri, $clean_url);
$generate_url = $this->style->buildUrl($original_uri, $clean_url);
// Ensure that the tests still pass when the file is generated by accessing
// a poorly constructed (but still valid) file URL that has an extra slash
......@@ -137,7 +136,7 @@ function _testImageStyleUrlAndPath($scheme, $clean_url = TRUE, $extra_slash = FA
if ($extra_slash) {
$modified_uri = str_replace('://', ':///', $original_uri);
$this->assertNotEqual($original_uri, $modified_uri, 'An extra slash was added to the generated file URI.');
$generate_url = image_style_url($this->style_name, $modified_uri, $clean_url);
$generate_url = $this->style->buildUrl($modified_uri, $clean_url);
}
if (!$clean_url) {
$this->assertTrue(strpos($generate_url, 'index.php/') !== FALSE, 'When using non-clean URLS, the system path contains the script name.');
......@@ -162,8 +161,8 @@ function _testImageStyleUrlAndPath($scheme, $clean_url = TRUE, $extra_slash = FA
$this->assertNotEqual(strpos($this->drupalGetHeader('Cache-Control'), 'no-cache'), FALSE, 'Cache-Control header contains \'no-cache\' to prevent caching.');
$this->assertEqual($this->drupalGetHeader('X-Image-Owned-By'), 'image_module_test', 'Expected custom header has been added.');
// Make sure that a second request to the already existing derivate works
// too.
// Make sure that a second request to the already existing derivative
// works too.
$this->drupalGet($generate_url);
$this->assertResponse(200, 'Image was generated at the URL.');
......@@ -177,9 +176,9 @@ function _testImageStyleUrlAndPath($scheme, $clean_url = TRUE, $extra_slash = FA
// make sure that access is denied.
$file_noaccess = array_shift($files);
$original_uri_noaccess = file_unmanaged_copy($file_noaccess->uri, $scheme . '://', FILE_EXISTS_RENAME);
$generated_uri_noaccess = $scheme . '://styles/' . $this->style_name . '/' . $scheme . '/'. drupal_basename($original_uri_noaccess);
$generated_uri_noaccess = $scheme . '://styles/' . $this->style->id() . '/' . $scheme . '/'. drupal_basename($original_uri_noaccess);
$this->assertFalse(file_exists($generated_uri_noaccess), 'Generated file does not exist.');
$generate_url_noaccess = image_style_url($this->style_name, $original_uri_noaccess);
$generate_url_noaccess = $this->style->buildUrl($original_uri_noaccess);
$this->drupalGet($generate_url_noaccess);
$this->assertResponse(403, 'Confirmed that access is denied for the private image style.');
......@@ -206,7 +205,6 @@ function _testImageStyleUrlAndPath($scheme, $clean_url = TRUE, $extra_slash = FA
// Create another working copy of the file.
$files = $this->drupalGetTestFiles('image');
$file = array_shift($files);
$image_info = image_get_info($file->uri);
$original_uri = file_unmanaged_copy($file->uri, $scheme . '://', FILE_EXISTS_RENAME);
// Let the image_module_test module know about this file, so it can claim
// ownership in hook_file_download().
......@@ -216,12 +214,12 @@ function _testImageStyleUrlAndPath($scheme, $clean_url = TRUE, $extra_slash = FA
// has not been created and try to create it. Check that the security token
// is not present in the URL but that the image is still accessible.
config('image.settings')->set('suppress_itok_output', TRUE)->save();
$generated_uri = image_style_path($this->style_name, $original_uri);
$generated_uri = $this->style->buildUri($original_uri);
$this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.');
$generate_url = image_style_url($this->style_name, $original_uri, $clean_url);
$generate_url = $this->style->buildUrl($original_uri, $clean_url);
$this->assertIdentical(strpos($generate_url, IMAGE_DERIVATIVE_TOKEN . '='), FALSE, 'The security token does not appear in the image style URL.');
$this->drupalGet($generate_url);
$this->assertResponse(200, 'Image was accessible at the URL with a missing token.');
}
}
......@@ -41,7 +41,7 @@ function testImageFormatterTheme() {
// Create a style.
$style = entity_create('image_style', array('name' => 'test', 'label' => 'Test'));
$style->save();
$url = image_style_url('test', $original_uri);
$url = $style->buildUrl($original_uri);
// Test using theme_image_formatter() without an image title, alt text, or
// link options.
......@@ -84,7 +84,7 @@ function testImageStyleTheme() {
// Create a style.
$style = entity_create('image_style', array('name' => 'image_test', 'label' => 'Test'));
$style->save();
$url = image_style_url('image_test', $original_uri);
$url = $style->buildUrl($original_uri);
$path = $this->randomName();
$element = array(
......
......@@ -182,7 +182,8 @@ public function _testPictureFieldFormatters($scheme) {
$display->setComponent($field_name, $display_options)
->save();
$this->drupalGet(image_style_url('large', $image_uri));
$large_style = entity_load('image_style', 'large');
$this->drupalGet($large_style->buildUrl($image_uri));
$image_info['uri'] = $image_uri;
$image_info['width'] = 480;
$image_info['height'] = 240;
......@@ -194,7 +195,7 @@ public function _testPictureFieldFormatters($scheme) {
if ($scheme == 'private') {
// Log out and try to access the file.
$this->drupalLogout();
$this->drupalGet(image_style_url('large', $image_uri));
$this->drupalGet($large_style->buildUrl($image_uri));
$this->assertResponse('403', 'Access denied to image style thumbnail as anonymous user.');
}
}
......
......@@ -225,7 +225,7 @@ function theme_picture($variables) {
// Fallback image, output as source with media query.
$sources[] = array(
'src' => image_style_url($variables['style_name'], $variables['uri']),
'src' => entity_load('image_style', $variables['style_name'])->buildUrl($variables['uri']),
'dimensions' => picture_get_image_dimensions($variables),
);
......@@ -244,7 +244,7 @@ function theme_picture($variables) {
// Only one image, use src.
if (count($new_sources) == 1) {
$sources[] = array(
'src' => image_style_url($new_sources[0]['style_name'], $new_sources[0]['uri']),
'src' => entity_load('image_style', $new_sources[0]['style_name'])->buildUrl($new_sources[0]['uri']),
'dimensions' => picture_get_image_dimensions($new_sources[0]),
'media' => $breakpoint->mediaQuery,
);
......@@ -253,7 +253,7 @@ function theme_picture($variables) {
// Multiple images, use srcset.
$srcset = array();
foreach ($new_sources as $new_source) {
$srcset[] = image_style_url($new_source['style_name'], $new_source['uri']) . ' ' . $new_source['#multiplier'];
$srcset[] = entity_load('image_style', $new_source['style_name'])->buildUrl($new_source['uri']) . ' ' . $new_source['#multiplier'];
}
$sources[] = array(
'srcset' => implode(', ', $srcset),
......@@ -338,7 +338,7 @@ function picture_get_image_dimensions($variables) {
'height' => $variables['height'],
);
image_style_transform_dimensions($variables['style_name'], $dimensions);
entity_load('image_style', $variables['style_name'])->transformDimensions($dimensions);
return $dimensions;
}
......@@ -101,7 +101,7 @@ function testNodeTeaser() {
// Construct the node and image URIs for testing.
$node_uri = url('node/' . $this->node->id(), array('absolute' => TRUE));
$image_uri = image_style_url('medium', $this->file->getFileUri());
$image_uri = entity_load('image_style', 'medium')->buildUrl($this->file->getFileUri());
// Test relations from node to image.
$expected_value = array(
......
......@@ -85,7 +85,7 @@ public function setUp() {
// Set URIs.
// Image.
$image_file = file_load($this->article->get('field_image')->offsetGet(0)->get('target_id')->getValue());
$this->imageUri = image_style_url('large', $image_file->getFileUri());
$this->imageUri = entity_load('image_style', 'large')->buildUrl($image_file->getFileUri());
// Term.
$term_uri_info = $this->term->uri();
$this->termUri = url($term_uri_info['path'], array('absolute' => TRUE));
......@@ -164,7 +164,7 @@ protected function _testFrontPageRDFa() {
// @todo Once the image points to the original instead of the processed
// image, move this to testArticleProperties().
$image_file = file_load($this->article->get('field_image')->offsetGet(0)->get('target_id')->getValue());
$image_uri = image_style_url('medium', $image_file->getFileUri());
$image_uri = entity_load('image_style', 'medium')->buildUrl($image_file->getFileUri());
$expected_value = array(
'type' => 'uri',
'value' => $image_uri,
......
......@@ -344,7 +344,7 @@ function rdf_preprocess_field(&$variables) {
// this field has a URI.
if (isset($item['entity']->uri)) {
if (!empty($element[$delta]['#image_style'])) {
$variables['item_attributes'][$delta]['resource'] = image_style_url($element[$delta]['#image_style'], $item['entity']->getFileUri());
$variables['item_attributes'][$delta]['resource'] = entity_load('image_style', $element[$delta]['#image_style'])->buildUrl($item['entity']->getFileUri());
}