data:view.featuredImage 는 data:blog.postImageUrl 와는 다르게 다음 표의 객체를 갖는다는 점을 제외하면 기능은 동일합니다. 본문에 포함된 N개 이미지 중에서 첫 번째 이미지를 반환합니다.

객 체 설 명
isResizable 이미지 크기를 조정할 수 있는지의 여부
true or false 중 하나
isYoutube 유튜브를 포함하고 있는지의 여부
true or false 중 하나
youtubeMaxResDefaultUrl 유튜브 썸네일 전체 이미지 URL
width 이미지 가로크기
height 이미지 세로크기
size 이미지 URL 문자열 수
length Size 와 동일함.


.isResizable

이미지 크기를 조정할 수 있는지의 여부를 판별하려면 .isResizable를 이용합니다. 조정 가능하면 true를 반환하고, 조정이 안되면 false를 반환합니다.

<b:if cond='data:view.featuredImage.isResizable'>
  <img expr:src='resizeImage(data:view.featuredImage,500,"1:1")'/>
</b:if>

다음의 삼항 연산자 방법도 가능합니다.

<b:if cond='data:view.featuredImage'>
  <img expr:src='
    data:view.featuredImage.isResizable ? resizeImage(data:view.featuredImage,500,"1:1")
    : data:view.featuredImage' />
</b:if>


.isYoutube

유튜브가 포함된 페이지이고 첫 번째 이미지가 유튜브이면 true 를 반환합니다.

<b:if cond='data:view.featuredImage.isYoutube'>
  <h1>첫 번째 이미지는 유뷰브입니다. </h1>
</b:if>

다음은 유튜브 이미지를 포함하고 있으면 <img…/> 태그를 출력하는 코드입니다.

<b:if cond='data:view.featuredImage.isYoutube'>
  <img
    expr:src='data:view.featuredImage.youtubeMaxResDefaultUrl'
    expr:width='data:view.featuredImage.width'
    expr:height='data:view.featuredImage.height'/>
</b:if>
<!--//
결과:
<img src='https://lh6.googleusercontent.com/proxy/KlVe…' width='480' height='360'/>
//-->

0 댓글