Unverified Commit f8c5df62 authored by Artem Dmitriiev's avatar Artem Dmitriiev Committed by Osman Gormus
Browse files

Issue #3327348 by a.dmitriiev: When using base64 encoded placeholder, use image style uri, not url

parent 4fbb2e21
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -203,10 +203,15 @@ function lazy_process_variables(array &$variables) {
        $placeholder_image_url = $style->buildUrl($file->getFileUri());
        // Serve as a data URI?
        if ($placeholder_data_uri) {
          // Requesting the URL will cause the image to be created.
          $content = @file_get_contents($placeholder_image_url);
          // Get placeholder image uri.
          $placeholder_image_uri = $style->buildUri($file->getFileUri());
          // Check if placeholder image already exists, if not - create it.
          if (!file_exists($placeholder_image_uri)) {
            $style->createDerivative($file->getFileUri(), $placeholder_image_uri);
          }
          $content = @file_get_contents($placeholder_image_uri);
          // Get the mime-type of the styled image, falls back to original.
          $mime_type = function_exists('mime_content_type') ? @mime_content_type($style->buildUri($file->getFileUri())) : $file->getMimeType();
          $mime_type = function_exists('mime_content_type') ? @mime_content_type($placeholder_image_uri) : $file->getMimeType();
          // Build the data URI with matching mime-type.
          $placeholder_image_url = "data:${mime_type};base64," . base64_encode($content);
        }