Skip Navigation
availability:

WPML Version: 4.6.10

description:

Note: This filter is available as of WPML Media Translation 2.7.4

This filter allows you to convert a media URL to the current language or a specified target language. If the language is not provided to the filter, it will default to using the current language.

type:
filter
category:
Retrieving Localized Content
parameters:
$url
(string) (Required) The media URL.
$language
(string) (Optional) The language code of the target language. The current language is the default.
hook example usage:

Example

// Convert the media URL to the current language.
apply_filters( 'wpml_media_url', 'https://example.com/wp-content/uploads/dog.jpg' );

// Convert the media URL to French.
apply_filters( 'wpml_media_url', 'https://example.com/wp-content/uploads/dog.jpg', 'fr' );

// Convert the media thumbnail URL to French.
apply_filters( 'wpml_media_url', 'https://example.com/wp-content/uploads/dog-150x150.jpg', 'fr' );