2012-06-02 2 views
3

우리는 이미지를 표시하기 위해 the_post_thumbnails을 사용합니다.워드 프레스 wp-post-image class remover

"test"라는 특정 클래스와 함께 사용하고 싶지만 관리 할 수 ​​없습니다!

우리는이 코드를 사용 :

<?php the_post_thumbnail('pin-photo-large', array('class' => 'test')); ?> 

그러나 이미지의 출력은 다음과 같이 보인다 :

class="test wp-post-image" 

우리가 어떻게이 문제를 극복하고이 같은 출력을 얻을 수

?

class="test" 
+0

이 왜 문제가 추가로'포스트 - 포스트 image'을 가지고 즐길? –

답변

2

업데이트 : 당신의 functions.php 파일이 추가 :

remove_action('begin_fetch_post_thumbnail_html', '_wp_post_thumbnail_class_filter_add'); 

설명 : media.php에서 _wp_post_thumbnail_class_filter 기능은 썸네일을 게시 할 wp-post-image 클래스를 추가합니다. 동작 후크가 인 begin_fetch_post_thumbnail_html을 제거하면이 기능은 더 이상 the_post_thumbnail에 적용되지 않습니다. 아래


올드 대답은 :

나는 또한 아무 소용 아아의 wp-post-image 클래스를 필터링 할 수있는 적절한 방법을 검색. 내가 알아 낸 유일한 해결책은 (!헐떡 거림)를 편집하는 것이었다 코어 파일 : media.php을이 대체 : 이것에 의해

function _wp_post_thumbnail_class_filter($attr) { 
    $attr['class'] .= ' wp-post-image'; 
    return $attr; 
} 

을 :

보다이 할 수있는 더 나은 방법이 확실히있다
function _wp_post_thumbnail_class_filter($attr) { 
    return $attr; 
} 

코어 파일을 패치하는 것은 좋은 임시 해결책이 될 수 있습니다.

0

functions.php 파일이 추가 :

function remove_post_image_class($content) { 
    $post_string = $content; 
    $post_string = preg_replace('/<img class=".*?"/', '<img', $post_string); 
    return $post_string; 
} 

add_filter('the_content', 'remove_post_image_class');