2

I have a carousel with Images and videos. The Image added appears but not videos. I am trying to assign a Video(mp4)media type using a Image Field type. When I am try to click the Browse and select a MP4 video I am getting an error as

The selected Item does not contain an Image.

Image: @Html.Sxa().Field(Templates.Carousel.Fields.Image, CarouselItem.Slider)

Video: @Html.Sxa().Field(Templates.Carousel.Fields.Video, CarouselItem.Slider)

  • So why do you want to use an 'Image Field' for videos? – TamerM Dec 26 '17 at 12:26
  • 1
    I want to give the user minimum access to load the content from media library only without using any custom field type. Is there any specific fields to handle such requirement? I know I can use "general link" Field type but with "Insert Media link" options it gives lots of other option like "Insert email" which I don't need. – Amitabh Dec 26 '17 at 14:11
  • Internal Link would do, it only provides one option to select a link – TamerM Dec 26 '17 at 14:21
  • Internal Link doesn't work as the video doesn't play on the browser. Can I use Movie Template, will it help? I am trying to play the video from the media library and I am working with SXA and Sitecore 9.0 – Amitabh Dec 27 '17 at 14:32
  • I don't think you can play videos in the content editor with any field type. The closest thing to this that I know is the 'File' type which has a 'View File' option that opens the video in a new tab and it starts playing. – TamerM Dec 27 '17 at 14:56
5

I don't think you can select videos using an 'Image' field out of the box. However, I don't see why you can't use other fields instead:

File: Allows users to search for files or simply browse the Media library and select the needed video

Attachment: directly upload from your machine (how to use in code)

Internal Link: displays the Select Link popup and you can select from the whole sitecore tree (you can set the datasource to 'sitecore/Media Library' only). To read the selected file, cast the field into LinkField and access the linkField variable's TargetItem (e.g. linkField1.TargetItem)

| improve this answer | |
2

I have followed "Internal Link" with Media Manager to make video(.mp4) running on the browser. The steps to achieve the same is as below:

  1. Use Internal Link Field rather than using Media or Image field.(Image field will give you an option to upload Videos but will throw an error when you select Video files as "Selected file does not contain an Image". Not sure why first of all Videos upload option are showing up in Image Field in such case.
  2. From the Path of the Internal Link get the Video Item and use MediaManager to get the url.

    MediaItem video = Sitecore.Context.Database.GetItem(videoPath);

    string src = Sitecore.Resources.Media.MediaManager.GetMediaUrl(video);

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.