WPML

问题概述

在使用 WPML 翻译带有 Themify Ultra 主题中 Feature Content 模块的页面时,图片的 ALT 文本在前端未翻译。

临时解决方法

此问题已在 Themify Ultra 8.0.1 中修复。 更新即可在您的站点上解决此问题,因此只有在您还无法更新时,才需要此临时解决方法。

在继续操作之前,请确保对站点进行了完整备份。

  • 打开 …/wp-content/themes/themify-ultra/themify/themify-builder/classes/class-themify-builder-model.php 文件。
  • 找到第 357 行。
  • 将:
    PHP
    public static function get_alt_by_url(string $image_url):string {
        $attachment_id = themify_get_attachment_id_from_url($image_url);
        if ($attachment_id && ($alt = get_post_meta($attachment_id, '_wp_attachment_image_alt', true))) {
            return $alt;
        }
        return '';
    }
  • 替换为:
    PHP
    public static function get_alt_by_url(string $image_url):string {
        $attachment_id = themify_get_attachment_id_from_url($image_url);
        // WPML Workaround for wpmlsupp-12600
        if ( class_exists('Sitepress') ) { 
            $current_lang = apply_filters( 'wpml_current_language', NULL ); 
            $attachment_id = apply_filters( 'wpml_object_id', $attachment_id, 'post', TRUE, $current_lang ); 
        }
        if ($attachment_id && ($alt = get_post_meta($attachment_id, '_wp_attachment_image_alt', true))) {
            return $alt;
        }
        return '';
    }

所有已知问题

仍然遇到此问题?

如果更新无法解决问题,请提出支持问题,我们将与您一起排查。