getThumbnail method
Uri
getThumbnail(
- Client sdn, {
- num? width,
- num? height,
- ThumbnailMethod? method = ThumbnailMethod.crop,
- bool? animated = false,
Returns a scaled thumbnail link to this content with the given width
and
height
. method
can be ThumbnailMethod.crop
or
ThumbnailMethod.scale
and defaults to ThumbnailMethod.scale
.
If animated
(default false) is set to true, an animated thumbnail is requested
as per MSC2705. Thumbnails only animate if the media repository supports that.
Implementation
Uri getThumbnail(Client sdn,
{num? width,
num? height,
ThumbnailMethod? method = ThumbnailMethod.crop,
bool? animated = false}) {
if (!isScheme('mxc')) return this;
final node = sdn.node;
if (node == null) {
return Uri();
}
return Uri(
scheme: node.scheme,
host: node.host,
path: '/_api/media/v3/thumbnail/$host${hasPort ? ':$port' : ''}$path',
port: node.port,
queryParameters: {
if (width != null) 'width': width.round().toString(),
if (height != null) 'height': height.round().toString(),
if (method != null) 'method': method.toString().split('.').last,
if (animated != null) 'animated': animated.toString(),
},
);
}