使用下面的代码,我为内容的所有图像添加了一些悬停共享图标。但是,现在这些图像没有得到作者的任何“链接到”设置。我不知道是什么问题。有谁可以请看下面的代码并指导我?
public function
Add_Pin_Button($content){
global $post;
// Get the post urls
$posturl = urlencode(get_permalink());
// Define a pattern to find all images inside the content
$pattern = '/<img(.*?)src="(.*?).(bmp|gif|jpeg|jpg|png)" (.*?) width="(.*?)" height="(.*?)" \/>/i';
// Replace the images with the following div and pin button
$button_div = '<div class="democlass">
<div class="secondclass">
<div class="thirdclass">
<a href="http://www.facebook.com/share.php?u=' . get_permalink().'&title='.get_the_title().'">
<img src="http://www.example.com/wp-content/facebook.png" width="45px" />
</a>
</div>
</div>
<div class="disdemo"><img$1src="$2.$3" $4 width="$5" height="$6" /></div> </div>
';
// Replace the images with a containing div with a pin button on the image
$content = preg_replace( $pattern, $button_div, $content );
return $content;
}
如何为内容的所有图片添加附件链接?