ภาพรวมของปัญหา
เมื่อแปลหน้าเว็บโดยใช้ WPML ร่วมกับโมดูล Feature Content ในธีม Themify Ultra ข้อความ 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 ''; }