WPML

問題の概要

Themify UltraテーマのFeature Contentモジュールを使用してWPMLでページを翻訳する場合、フロントエンドで画像の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 '';
    }

すべての既知の問題

まだこの問題が発生しますか?

アップデートしても問題が解決しない場合は、サポートのご質問をお寄せください。一緒に調査いたします。