You are here

public static function EmbedButton::convertImageToEncodedData in Embed 8

Convert a file on the filesystem to encoded data.

Parameters

string $uri: An image file URI.

Return value

array An array of data about the encoded image including:

  • uri: The URI of the file.
  • data: The base-64 encoded contents of the file.

Overrides EmbedButtonInterface::convertImageToEncodedData

2 calls to EmbedButton::convertImageToEncodedData()
EmbedButtonForm::save in src/Form/EmbedButtonForm.php
Form submission handler for the 'save' action.
IconTest::testIcon in tests/src/Kernel/IconTest.php
Tests the icon functionality.

File

src/Entity/EmbedButton.php, line 186

Class

EmbedButton
Defines the EmbedButton entity.

Namespace

Drupal\embed\Entity

Code

public static function convertImageToEncodedData($uri) {
  return [
    'data' => base64_encode(file_get_contents($uri)),
    'uri' => $uri,
  ];
}