video_tag
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0
- 2.2.1
- 2.3.8
- 3.0.0 (0)
- 3.0.9 (-7)
- 3.1.0 (0)
- 3.2.1 (0)
- 3.2.8 (0)
- 3.2.13 (0)
- 4.0.2 (13)
- 4.1.8 (19)
- 4.2.1 (5)
- 4.2.7 (0)
- 4.2.9 (0)
- 5.0.0.1 (0)
- 5.1.7 (38)
- 5.2.3 (-1)
- 6.0.0 (0)
- 6.1.3.1 (0)
- 6.1.7.7 (0)
- 7.0.0 (0)
- 7.1.3.2 (30)
- 7.1.3.4 (0)
- What's this?
video_tag(*sources)
public
Returns an html video tag for the sources. If sources is a string, a single video tag will be returned. If sources is an array, a video tag with nested source tags for each source will be returned. The sources can be full paths or files that exists in your public videos directory.
Options
You can add HTML attributes using the options. The options supports two additional keys for convenience and conformance:
-
:poster - Set an image (like a screenshot) to be shown before the video loads. The path is calculated like the src of image_tag.
-
:size - Supplied as “{Width}x{Height}”, so “30x45” becomes width=“30” and height=“45”. :size will be ignored if the value is not in the correct format.
Examples
video_tag("trailer") # => <video src="/videos/trailer" /> video_tag("trailer.ogg") # => <video src="/videos/trailer.ogg" /> video_tag("trailer.ogg", controls: true, autobuffer: true) # => <video autobuffer="autobuffer" controls="controls" src="/videos/trailer.ogg" /> video_tag("trailer.m4v", size: "16x10", poster: "screenshot.png") # => <video src="/videos/trailer.m4v" width="16" height="10" poster="/assets/screenshot.png" /> video_tag("/trailers/hd.avi", size: "16x16") # => <video src="/trailers/hd.avi" width="16" height="16" /> video_tag("/trailers/hd.avi", height: '32', width: '32') # => <video height="32" src="/trailers/hd.avi" width="32" /> video_tag("trailer.ogg", "trailer.flv") # => <video><source src="/videos/trailer.ogg" /><source src="/videos/trailer.flv" /></video> video_tag(["trailer.ogg", "trailer.flv"]) # => <video><source src="/videos/trailer.ogg" /><source src="/videos/trailer.flv" /></video> video_tag(["trailer.ogg", "trailer.flv"], size: "160x120") # => <video height="120" width="160"><source src="/videos/trailer.ogg" /><source src="/videos/trailer.flv" /></video>