Bỏ qua điều hướng

Waiting for author

Topic Tags: Compatibility

Overview of the issue

When translating a page using WPML with the Feature Content module in the Themify Ultra theme, the ALT text for images are not translated on the front-end.

Workaround

Please, make sure of having a full site backup of your site before proceeding.

  • Open the …/wp-content/themes/themify-ultra/themify/themify-builder/classes/class-themify-builder-model.php file.
  • Look for line 357.
  • Replace:
        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 '';
        }
            
  • With:
        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 '';
        }
            

Để lại phản hồi

Vui lòng bám sát chủ đề và tôn trọng người khác. Nếu bạn cần trợ giúp với các vấn đề không liên quan đến bài đăng này, hãy sử dụng Diễn đàn Hỗ trợ của chúng tôi để bắt đầu trò chuyện hoặc gửi yêu cầu hỗ trợ.

Bạn có thể sử dụng các thẻ sau:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>