douaipi3965 2017-03-01 10:00
浏览 45
已采纳

如何在主页上的精选图片中放置图库图标?

if you check Marie Claire website :http://www.marieclaire.fr/

in each post that have slider gallery inside , they put a small icon gallery on the featured image of the post . what the condition to put it , how can be done for a WordPress website ?? image click on it

i have this code for show image :

function show_image($args, $caption = '')
{
  $postid = '';
  $video = '';
  $image_size = 'large';
  $before = '';
  $after = '';
  $display = true;
  $img_str = '';
  $issingle = false;
  extract($args);
  if($postid == '')
  {
    return false;
  }
  $videostyle = "";
  $isvideo = isvideopost($postid);

  $img_str = "";
  $thumbid = get_post_thumbnail_id( $postid );
  $image = wp_get_attachment_image_src( get_post_thumbnail_id( $postid ), $image_size );
  if($image)
  {
    $image_file = $image[0];
    $img_str .= $before;
      if($isvideo == true && $issingle == false){
        $img_str .= '<div class="videoimage">';
        $videostyle = 'style="position: relative; top: 0; left: 0;"';
      }elseif(has_term( 'video', 'post_tag',$postid)==true && $issingle == false){
        $img_str .= '<div class="videoimage">';
        $videostyle = 'style="position: relative; top: 0; left: 0;"';
      }
      $img_str .= '<img src="'.$image_file.'" '.$videostyle.'>';
      if($isvideo == true && $issingle == false){
        $img_str .= '<img src="'.THEME_URL.'/images/playicon/playicon_'.$image_size.'.png" style="position: absolute; top: 0; left: 0;"/>';
        $img_str .= '</div>';
      }elseif(has_term( 'video', 'post_tag',$postid)==true && $issingle == false){
        $img_str .= '<img src="'.THEME_URL.'/images/playicon/playicon_'.$image_size.'.png" style="position: absolute; top: 0; left: 0;"/>';
        $img_str .= '</div>';
      }
    $img_str .= $after;
    if($display == true)
    {
      echo $img_str;
    }else{
      return $img_str;
    }
  }else{
    return false;
  }
}

what i need is to add codition if exist attachements image to show this icon on featured image

</div>
  • 写回答

1条回答 默认 最新

  • douxiuar885064 2017-03-01 10:05
    关注

    You can directly upload a image from Set featured image link in the post. And you access it using the_post_thumbnail( 'thumbnail' );. You can get more idea from https://developer.wordpress.org/reference/functions/the_post_thumbnail/ .

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥500 求华为P30PRO手机硬盘数据恢复
  • ¥15 关于#vscode#的问题:ESP32开发板对接MQTT实现小灯泡的开关
  • ¥15 TMC2209串口模式下读取不到寄存器的值串口助手蓝色字体是发过去的消息,绿色字体是收到的消息,第二行发送读取寄存器的指令但是没有读取到寄存器的值串口助手如下图:接线如下图,如何解决?
  • ¥15 怎样删除 右键菜单里的 剪切(T)和复制(C)
  • ¥15 高通安卓11提取完整线刷包软件,或者优博讯dt50顺丰刷机包
  • ¥20 C,有个译码器,换了信道就跑不出原来数据
  • ¥15 MIMIC数据库安装问题
  • ¥60 基于JTag协议开发Fpga下载器上位机,哪位大🐂有偿指导?
  • ¥20 全书网Java爬取数据
  • ¥15 怎么获取红包封面的原始链接,并且获取红包封面序列号