0

我有一个自定义博客模板,它在主页上显示帖子的图像和帖子标题(链接到帖子)。我需要做的是将该图像链接到帖子网址,我已经厌倦了链接图像但整个代码中断

这是头部的java脚本代码

<script type='text/javascript'>
var thumbnail_mode = &quot;float&quot; ;
summary_noimg = 250;
summary_img = 250;
</script>
<script type='text/javascript'>
//<![CDATA[
function removeHtmlTag(strx,chop){
if(strx.indexOf("<")!=-1)
{
var s = strx.split("<");
for(var i=0;i<s.length;i++){
if(s[i].indexOf(">")!=-1){
s[i] = s[i].substring(s[i].indexOf(">")+1,s[i].length);
}
}
strx = s.join("");
}
chop = (chop < strx.length-1) ? chop : strx.length-2;
while(strx.charAt(chop-1)!=' ' && strx.indexOf(' ',chop)!=-1) chop++;
strx = strx.substring(0,chop-1);
return strx+'.';
}
function createSummaryAndThumb(pID){
var div = document.getElementById(pID);
var imgtag = "";
var img = div.getElementsByTagName("img");
var summ = summary_noimg;
if(img.length>=1) {
  imgtag = '<div class="crop"><img src="'+img[0].src+'" width="300px;" height="350px;"/></div>';
summ = summary_img;
}
var summary = imgtag + '<div class="posting">' + '</div>';
div.innerHTML = summary;
}
//]]>
</script>

正文部分的代码

<div class='cover'>
<a expr:name='data:post.id'/>
    <b:if cond='data:post.title'>
      <h2>
     <b:if cond='data:post.link'>
       <a expr:href='data:post.link' expr:title='&quot;Permanent Link to &quot; + data:post.title' rel='bookmark'><data:post.title/></a>
     <b:else/>
        <b:if cond='data:post.url'>
          <a expr:href='data:post.url' expr:title='&quot;Permanent Link to &quot; + data:post.title' rel='bookmark'><data:post.title/></a>
        <b:else/>
          <data:post.title/>
        </b:if>
     </b:if>
      </h2>
    </b:if>


<div class='jomore'><div class='jomorelink'><a class='anes' expr:href='data:post.url'>&#9658;</a></div></div>
        <div class='bgjo'><div expr:id='&quot;summary&quot; + data:post.id'><a expr:href='data:post.url'><data:post.body/></a></div></div>
        <script type='text/javascript'>createSummaryAndThumb(&quot;summary<data:post.id/>&quot;);</script>
        <div style='clear: both;'/> <!-- clear for photos floats -->
      </div>
4

1 回答 1

0

在java代码中

替换这个

if(img.length>=1) {
  imgtag = '<div class="crop"><img src="'+img[0].src+'" width="300px;" height="350px;"/></div>';
summ = summary_img;

if(img.length>=1) {
  imgtag = '<div class="crop"> <a expr:href='data:post.link' ><img src="'+img[0].src+'" width="300px;" height="350px;"/></a></div>';
summ = summary_img;
于 2013-10-14T17:58:17.553 回答