Add picture_tag to ActionView helpers guides [ci skip]

This commit is contained in:
Guillaume Wrobel 2023-11-04 20:47:29 +01:00
parent 4161ae7d7c
commit 07ed4f87e4
No known key found for this signature in database
GPG Key ID: DED04BEC562A2B65
1 changed files with 18 additions and 0 deletions

View File

@ -99,6 +99,24 @@ javascript_url "common"
# => http://www.example.com/assets/common.js
```
#### picture_tag
Returns an HTML picture tag for the source. It supports passing a String, an Array or a Block.
```ruby
picture_tag("icon.webp", "icon.png")
```
This generates the following HTML:
```html
<picture>
<source srcset="/assets/icon.webp" type="image/webp" />
<source srcset="/assets/icon.png" type="image/png" />
<img src="/assets/icon.png" />
</picture>
```
#### preload_link_tag
Returns a link tag that browsers can use to preload the source. The source can be the path of a resource managed by asset pipeline, a full path, or an URI.