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/ .

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

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!