API Docs for: 0.8.0
Show:

MediaService Class

This class is deprecated.

Provides information on media

Constructor

MediaService

(
  • provider
  • site
  • onlyThisSite
)
deprecated

Parameters:

  • provider MediaProvider
  • site String

    Site uid to be used for this service

  • onlyThisSite Boolean

    Whether this service should only return media associated with specified site or fallback to global if not found in specified site

Item Index

Methods

Properties

Methods

.

(
  • content
)
Object static

Parses a media flag and returns each part in an object. The parsed value that is returned will include:

  • id - The media descriptor id that is referenced by the media flag
  • style - A hash of the style properties declared for the flag
  • cleanFlag - The media flag stripped of the start and end markers

Parameters:

  • content String

    The content string that potentially contains 1 or more media flags

Returns:

Object:

An object that contains the information about the parsed media flag.

createContentWriteStream

(
  • fileName
  • cb
)

Parameters:

  • fileName String
  • cb Function

deleteById

(
  • mid
  • [options]
  • cb
)

Deletes a media descriptor by ID

Parameters:

  • mid String | ObjectID
  • [options] Object optional

    not used in implementation

  • cb Function

deleteContentByPath

(
  • mediaPath
  • cb
)

Parameters:

  • mediaPath String
  • cb Function

existsByPath

(
  • mediaPath
  • cb
)

Parameters:

  • mediaPath String
  • cb Function

extractNextMediaFlag

(
  • content
)
Object deprecated static

Given a content string the function will search for and extract the first occurrence of a media flag. The parsed value that is returned will include:

  • startIndex - The index where the flag was found to start
  • endIndex - The position in the content string of the last character of the media flag
  • flag - The entire media flag including the start and end markers
  • id - The media descriptor id that is referenced by the media flag
  • style - A hash of the style properties declared for the flag
  • cleanFlag - The media flag stripped of the start and end markers

Parameters:

  • content String

    The content string that potentially contains 1 or more media flags

Returns:

Object:

An object that contains the information about the parsed media flag.

findProviderType

() MediaProvider deprecated static

Looks up the prototype for the media provider based on the configuration

Returns:

MediaProvider:

formatMedia

(
  • media
)
Array deprecated static

Sets the proper icon and link for an array of media items

Parameters:

  • media Array

    The array of media objects to format

Returns:

Array:

The same array of media that was passed in

generateFilename

(
  • originalFilename
)
String deprecated static

Generates a filename for a new media object

Parameters:

  • originalFilename String

Returns:

String:

generateMediaPath

(
  • originalFilename
)
String deprecated static

Generates the path to uploaded media

Parameters:

  • originalFilename String

Returns:

String:

get

(
  • [options]
  • cb
)

Queries for media descriptors

Parameters:

  • [options] Object optional
    • [where] Object optional
    • [order] Array optional
    • [select] Object optional
    • [limit] Integer optional
    • [offset] Integer optional
    • [format_media=true] Boolean optional
  • cb Object

getContentByPath

(
  • mediaPath
  • cb
)

Parameters:

  • mediaPath String
  • cb Function

getContentStreamById

(
  • id
  • cb
)

Parameters:

  • id String
  • cb Function

getContentStreamByPath

(
  • mediaPath
  • cb
)

Parameters:

  • mediaPath String
  • cb Function

getMediaDescriptor

(
  • mediaUrl
  • cb
)

Generates a media descriptor for a given media URL

Parameters:

  • mediaUrl String
  • cb Function

    A callback with two parameters. First, an Error if occurred and second is an object that describes the media resource described by the given media URL

getMediaFlag

(
  • mid
  • [options]
)
String deprecated static

Generates a media placeholder for templating

Parameters:

  • mid String

    The media descriptor ID

  • [options] Object optional

    The list of attributes to be provided to the rendering element.

Returns:

String:

getMediaIcon

(
  • mediaType
)
String deprecated static

Retrieves the font awesome icon for the media type.

Parameters:

  • mediaType String

Returns:

String:

getRendererByType

(
  • mediaUrl
  • isFile
)
MediaRenderer deprecated static

Retrieves a media renderer for the specified URL

Parameters:

  • mediaUrl String

    The media URL

  • isFile Boolean

    TRUE if the URL represents an uploaded file, FALSE if not

Returns:

MediaRenderer:

A media renderer interface implementation or NULL if none support the given URL.

getRendererByType

(
  • type
)
MediaRenderer deprecated static

Retrieves a media renderer for the specified type

Parameters:

  • type String

    The media type

Returns:

MediaRenderer:

A media renderer interface implementation or NULL if none support the given type.

getStyleForPosition

(
  • position
)
String deprecated static

The default editor implementations all for three position values to declared for embeded media (none, left, right, center). These values map to HTML alignments. This function retrieves the HTML style attribute for the provided position.

Parameters:

  • position String

    Can be one of 4 values: none, left, right, center

Returns:

String:

The HTML formatted style attribute(s)

getStyleForView

(
  • renderer
  • view
  • [overrides]
)
deprecated static

Retrieves the base style for the given renderer and view. Overrides will be applied on top of the base style.

Parameters:

  • renderer MediaRenderer

    An implementation of MediaRenderer

  • view String

    The view to retrieve the default styling for (view, editor, post)

  • [overrides] Object optional

    A hash of style properties that will be applied to the base style for the given view

getSupportedExtensions

() Array deprecated static

Provides a mechanism to retrieve all of the supported extension types that can be uploaded into the system.

Returns:

Array:

provides an array of strings

isFile

(
  • mediaUrl
)
deprecated static

Determines if the media URI is a file. It is determined to be a file if and only if the URI does not begin with "http" or "//".

Parameters:

  • mediaUrl String

    A URI string that points to a media resource

isRegistered

(
  • interfaceImplementation
)
Boolean deprecated static

Indicates if a media renderer is already registered

Parameters:

  • interfaceImplementation Function | Object

    A prototype or object that implements the media renderer interface

Returns:

Boolean:

TRUE if registered, FALSE if not

isValidFilePath

(
  • mediaPath
  • cb
)

Retrieves whether a media's file path is valid

Parameters:

  • mediaPath String

    The file path of the media

  • cb Function

    Callback function

loadById

(
  • mid
  • cb
)

Loads a media descriptor by ID.

Parameters:

  • mid String | ObjectID

    Media descriptor ID

  • cb Function

    A callback that provides two parameters: an Error, if occurred and a media descriptor if found.

loadMediaProvider

(
  • context
)
MediaProvider deprecated static

Parameters:

  • context Object
    • site String

Returns:

MediaProvider:

An instance of a media provider or NULL when no provider can be loaded.

registerRenderer

(
  • interfaceImplementation
)
Boolean deprecated static

Registers a media renderer

Parameters:

  • interfaceImplementation Function | Object

    A prototype or object that implements the media renderer interface.

Returns:

Boolean:

TRUE if the implementation was registered, FALSE if not

render

(
  • The
  • options
  • cb
)

Renders the media represented by the provided media descriptor.

Parameters:

  • The String

    media resource ID

  • options Object
    • [attrs] Object optional

      The desired HTML attributes that will be added to the element that provides the rendering

    • [style] Object optional

      The desired style overrides for the media

    • [view] String optional

      The view type that the media will be rendered for (view, editor, post). Any style options provided will override those provided by the default style associated with the view.

  • cb Function

    A callback that provides two parameters. An Error if exists and the rendered HTML content for the media resource.

render

(
  • flag
  • options
  • cb
)

Renders the media represented by the provided media flag

Parameters:

  • flag String | Object

    The media resource ID

  • options Object
    • [attrs] Object optional

      The desired HTML attributes that will be added to the element that provides the rendering

    • [style] Object optional

      The desired style overrides for the media

    • [view] String optional

      The view type that the media will be rendered for (view, editor, post). Any style options provided will override those provided by the default style associated with the view.

  • cb Function

    A callback that provides two parameters. An Error if exists and the rendered HTML content for the media resource.

renderById

(
  • id
  • options
  • cb
)

Renders a media resource by ID where ID refers the to the media descriptor id.

Parameters:

  • id String

    The media resource ID

  • options Object
    • [attrs] Object optional

      The desired HTML attributes that will be added to the element that provides the rendering

    • [style] Object optional

      The desired style overrides for the media

    • [view] String optional

      The view type that the media will be rendered for (view, editor, post). Any style options provided will override those provided by the default style associated with the view.

  • cb Function

    A callback that provides two parameters. An Error if exists and the rendered HTML content for the media resource.

renderByLocation

(
  • options
  • cb
)

Renders a resource by type and location (mediaId).

Parameters:

  • options Object
    • location String

      The unique media identifier for the type

    • [type] String optional

      The type of provider that knows how to render the resource

    • [attrs] Object optional

      The desired HTML attributes that will be added to the element that provides the rendering

    • [style] Object optional

      The desired style overrides for the media

    • [view] String optional

      The view type that the media will be rendered for (view, editor, post). Any style options provided will override those provided by the default style associated with the view.

    • [isFile=false] Boolean optional
  • cb Function

    A callback that provides two parameters. An Error if exists and the rendered HTML content for the media resource.

save

(
  • media
  • [options]
  • cb
)

Persists a media descriptor

Parameters:

  • media Object
  • [options] Object optional

    Options object is not actually used in this implementation

  • cb Function

setContent

(
  • fileDataStrOrBuff
  • fileName
  • cb
)

Parameters:

  • fileDataStrOrBuff String | Buffer
  • fileName String
  • cb Function

setContentStream

(
  • stream
  • fileName
  • cb
)

Parameters:

  • stream Stream
  • fileName String
  • cb Function

statByPath

(
  • mediaPath
  • cb
)

Parameters:

  • mediaPath String
  • cb Function

unregisterRenderer

(
  • interfaceToUnregister
)
Boolean deprecated static

Unregisters a media renderer

Parameters:

  • interfaceToUnregister Function | Object

    A prototype or object that implements the media renderer interface

Returns:

Boolean:

TRUE if unregistered, FALSE if not

validate

(
  • media
  • cb
)

Validates a media descriptor

Parameters:

  • media Object
  • cb Function

    A callback that provides two parameters: an Error, if occurred. The second is an array of validation error objects.

Properties

COLL

String static

The collection where media descriptors are persisted

provider

MediaProvider