wpml_media_url
- Type
- filter
- Category
- Retrieving Localized Content
- 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.
Arguments
- $url
- (string) (Required) The media URL.
- $language
- (string) (Optional) The language code of the target language. The current language is the default.
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' );
Related hooks
wpml_media_id, force_suppress_filters, wpml_get_translated_slug, wpml_home_url, wpml_translate_single_string, wpml_translate_string, wpml_elements_without_translations, wpml_permalink, wpml_unfiltered_admin_string, wpml_element_link