SHARE
TWEET

Untitled

a guest Jun 26th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function slider_get_uri_by_media($media, $style = 'background'){
  2.   // kint(isset($media->file_media_video_file));
  3.   if (isset($media->field_media_image)){
  4.     $file = $media->field_media_image->entity;
  5.     if ($file && $fid = $file->id()) {
  6.       $image = File::load($fid);
  7.       if ($image_style = ImageStyle::load($style)) {
  8.         return ['url' => file_url_transform_relative($image_style->buildUrl($image->getFileUri()))];
  9.       }
  10.     }
  11.   }
  12.   elseif (isset($media->file_media_video_file)) {
  13.     $file = $media->file_media_video_file->entity;
  14.     if ($file && $fid = $file->id()) {
  15.       $video = File::load($fid);
  16.     }
  17.   }
  18. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top