function ImageStyleFlushTest::createSampleImage

Same name in other branches
  1. 9 core/modules/image/tests/src/Functional/ImageStyleFlushTest.php \Drupal\Tests\image\Functional\ImageStyleFlushTest::createSampleImage()
  2. 8.9.x core/modules/image/tests/src/Functional/ImageStyleFlushTest.php \Drupal\Tests\image\Functional\ImageStyleFlushTest::createSampleImage()
  3. 10 core/modules/image/tests/src/Functional/ImageStyleFlushTest.php \Drupal\Tests\image\Functional\ImageStyleFlushTest::createSampleImage()
  4. 11.x core/modules/image/tests/src/Functional/ImageStyleFlushTest.php \Drupal\Tests\image\Functional\ImageStyleFlushTest::createSampleImage()

Given an image style and a wrapper, generate an image.

1 call to ImageStyleFlushTest::createSampleImage()
ImageStyleFlushTest::testFlush in modules/image/image.test
General test to flush a style.

File

modules/image/image.test, line 1973

Class

ImageStyleFlushTest
Tests flushing of image styles.

Code

function createSampleImage($style, $wrapper) {
    static $file;
    if (!isset($file)) {
        $files = $this->drupalGetTestFiles('image');
        $file = reset($files);
    }
    // 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['name'], $source_uri);
    $derivative = image_style_create_derivative($style, $source_uri, $derivative_uri);
    return $derivative ? $derivative_uri : FALSE;
}

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