wpml_media_url
- 类型
- filter
- 类别
- 获取本地化内容
- WPML 版本
- 4.6.10
说明
注意:此过滤器自 WPML Media Translation 2.7.4 起可用
此过滤器可让您将媒体 URL 转换为当前语言或指定的目标语言。如果未向过滤器提供语言,它将默认使用当前语言。
参数
- $url
- (字符串) (必填) 媒体 URL。
- $language
- (字符串) (可选) 目标语言的语言代码。当前语言为默认语言。
使用示例
示例
// 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' );
相关钩子
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