2013-11-03 68 views
0

我试图编辑添加图像的输出在帖子来自WordPress的正常码是修改HTML输出时的文章和网页加载图像

<a href="http://huemix.ly/wp-content/pics/pic.jpg"><img src="http://huemix.ly/wp-content/pics/pic.jpg" /></a> 

我希望替换输出与

<div class="huemix"> 
    <img class="posts-img" src="http://huemix.ly/wp-content/pics/pic.jpg" /> 
    <a href="http://huemix.ly/wp-content/pics/pic.jpg" class="fancybox" ></a> 
    <div class="fancy"></div> 
</div> 

我所有的尝试下降:(

回答

2

您需要搜索的WordPress的功能文件中的代码正确块。该文件应该被命名为post.php,并应设在wp-includes。函数名称应该是wp_insert_attachment()

或者使用过滤器:

<?php 
     add_filter('image_send_to_editor', 'my_image_func', 10, 7); 
     function my_image_func($html, $id, $alt, $title, $align, $url, $size) { 
      $url = wp_get_attachment_url($id); // Grab the current image URL 
      $html = "<img src="$url" class="uhuhu"/>"; 
      return $html; 
     } 
?>