Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement