z_media_tag (zotonic_core v1.0.0-rc.17)
Generate media urls and html for viewing media, based on the filename, size and optional filters. Does not generate media previews itself, this is done when fetching the image.
Typical urls are like: /image/2007/03/31/wedding.jpg(300x300)(crop-center)(a3ab6605e5c8ce801ac77eb76289ac12).jpg /media/inline/2007/03/31/wedding.jpg /media/attachment/2007/03/31/wedding.jpg
Summary
Functions
Generate a HTML image tag attributes for the image with the filename and options. The medium _must_ be in a format for which we can generate a preview. Note that this will never generate video or audio.
Generate a 'data:' url for the given image.
Called from template, render the media tag for some resource/medium
Called from template, render the media url for some resource/medium
Called from template, render the media viewer for some resource/medium
Generate a HTML image tag for the image with the filename and options. The medium _must_ be in a format for which we can generate a preview. Note that this will never generate video or audio.
Translate an url of the format "image.jpg(300x300)(crop-center)(checksum).jpg" to parts
Generate the url for the image with the filename and options
Generate a html fragment for displaying a medium. This can generate audio or video player html.
Types
-type fileref() :: file:filename_all() | {filepath, file:filename_all(), file:filename_all()}.
-type mediaref() :: undefined | m_rsc:resource_id() | z_media_identify:media_info() | #rsc_list{list :: [m_rsc:resource_id()]} | proplists:proplist() | file:filename_all().
-type viewer_options() :: proplists:proplist().
Functions
-spec attributes(MediaReference, Options, Context) -> {ok, Attrs} | {error, Reason} when MediaReference :: mediaref(), Options :: viewer_options(), Context :: z:context(), Attrs :: [{atom(), iodata()}], Reason :: enoent.
Generate a HTML image tag attributes for the image with the filename and options. The medium _must_ be in a format for which we can generate a preview. Note that this will never generate video or audio.
Generate a 'data:' url for the given image.
Called from template, render the media tag for some resource/medium
Called from template, render the media url for some resource/medium
Called from template, render the media viewer for some resource/medium
-spec tag(MediaReference, Options, Context) -> {ok, ImgTag} when MediaReference :: mediaref(), Options :: viewer_options(), Context :: z:context(), ImgTag :: binary().
Generate a HTML image tag for the image with the filename and options. The medium _must_ be in a format for which we can generate a preview. Note that this will never generate video or audio.
-spec url2props(binary() | string(), z:context()) -> {ok, {FilePath :: string(), Props :: list(), Checksum :: string(), ChecksumBaseString :: string()}} | {error, no_lparen | checksum_invalid | extension_invalid | badarg}.
Translate an url of the format "image.jpg(300x300)(crop-center)(checksum).jpg" to parts
-spec url(MediaRef, Options, Context) -> {ok, Url} | {error, Reason} when MediaRef :: mediaref(), Options :: viewer_options(), Context :: z:context(), Url :: binary(), Reason :: enoent.
Generate the url for the image with the filename and options
-spec viewer(MediaReference, Options, Context) -> {ok, HTML} when MediaReference :: mediaref(), Options :: viewer_options(), Context :: z:context(), HTML :: iodata().
Generate a html fragment for displaying a medium. This can generate audio or video player html.