Struct silkenweb_html::elements::SourceBuilder
source · pub struct SourceBuilder(_);
Implementations§
source§impl SourceBuilder
impl SourceBuilder
pub fn id(self, value: impl AttributeValue<String>) -> Self
pub fn class(self, value: impl AttributeValue<String>) -> Self
sourcepub fn media(self, value: impl AttributeValue<String>) -> Self
pub fn media(self, value: impl AttributeValue<String>) -> Self
Media query of the resource’s intended media; this should be used only in a <picture>
element.
sourcepub fn sizes(self, value: impl AttributeValue<String>) -> Self
pub fn sizes(self, value: impl AttributeValue<String>) -> Self
Is a list of source sizes that describes the final rendered width of the image represented by the source. Each source size consists of a comma-separated list of media condition-length pairs. This information is used by the browser to determine, before laying the page out, which image defined in srcset to use. Please note that sizes will have its effect only if width dimension descriptors are provided with srcset instead of pixel ratio values (200w instead of 2x for example).
The sizes attribute has an effect only when the <source>
element is the direct child of
a <picture>
element.
sourcepub fn src(self, value: impl AttributeValue<String>) -> Self
pub fn src(self, value: impl AttributeValue<String>) -> Self
Required for <audio>
and <video>
, address of the media resource. The value of this
attribute is ignored when the <source>
element is placed inside a <picture>
element.
sourcepub fn srcset(self, value: impl AttributeValue<String>) -> Self
pub fn srcset(self, value: impl AttributeValue<String>) -> Self
A list of one or more strings separated by commas indicating a set of possible images represented by the source for the browser to use. Each string is composed of:
- One URL specifying an image.
- A width descriptor, which consists of a string containing a positive integer directly followed by “w”, such as 300w. The default value, if missing, is the infinity.
- A pixel density descriptor, that is a positive floating number directly followed by “x”. The default value, if missing, is 1x.
Each string in the list must have at least a width descriptor or a pixel density descriptor to be valid. Among the list, there must be only one string containing the same tuple of width descriptor and pixel density descriptor. The browser chooses the most adequate image to display at a given point of time.
The srcset attribute has an effect only when the <source>
element is the direct child of
a <picture>
element.
sourcepub fn type_(self, value: impl AttributeValue<String>) -> Self
pub fn type_(self, value: impl AttributeValue<String>) -> Self
The MIME media type of the resource, optionally with a codecs parameter.