WPML
상태
미해결
보고된 제품
WPML Media Translation 2.7.0
관련 플러그인/테마
SVG Support
주제 태그
Compatibility

문제 개요

SVG Support 플러그인을 사용 중인 경우, WPML Media Translation 플러그인이 활성화되어 있으면 SVG 이미지 URL이 불완전하게 표시되는 것을 확인할 수 있습니다. 예:

  • WPML Media Translation을 활성화한 경우: https://domain.com/wp-content/uploads/logo.svg
  • WPML Media Translation을 활성화하지 않은 경우: https://domain.com/wp-content/uploads/2022/05/logo.svg

임시 해결 방법

  • 테마의 functions.php 파일에 다음 스니펫을 추가하세요:
    // WPML Workaround for compsupp-6933
    add_filter('wp_get_attachment_metadata', 'wpml_compsupp6933_fix_attachment_metadata_file_path', 10, 2);
    
    function wpml_compsupp6933_fix_attachment_metadata_file_path($data, $attachment_id) {
    
    	// Only apply the workaround if WPML Media and SVG Support plugins are active
    	if( class_exists('WPML_Media') && function_exists('bodhi_svgs_generate_svg_attachment_metadata') ) {
    		
    		if (isset($data['file']) && !preg_match('/\d{4}\/\d{2}\//', $data['file'])) {
    			// Get the upload directory info
    			$upload_dir_info = wp_upload_dir();
    	
    			// Extract the year and month from the basedir
    			$year_month = date('Y/m', strtotime(get_post_field('post_date', $attachment_id)));
    	
    			// Prepend the year and month to the file
    			$data['file'] = $year_month . '/' . $data['file'];
    			
    		}
    	}    
    
        return $data;
    }

알려진 모든 문제 →