feat(content): 본문 이미지 목록 썸네일·og:image 폴백 전 티어 구현
공개 이슈 https://github.com/gnuboard/g7/issues/22 — 본문에 삽입한 이미지가 카드/갤러리 목록 썸네일과 공유 미리보기(og:image)에 반영되지 않던 공백을 코어+3모듈+2템플릿에서 해소. - 코어 7.0.9: HtmlImageExtractor(내부 이미지 한정, origin 정규화 SSoT 재사용) + seo.og_image_default 사이트 기본 공유 이미지 설정 + SeoMetaResolver 폴백 체인 - board 1.1.0 / ecommerce 1.2.0 / page 1.1.0: content_thumbnail_url 캐시 컬럼, saving 추출(html 모드 한정·첨부 우선·비밀글 게이트 유지), filter_content_thumbnail 훅, 기존 데이터 백필 업그레이드 스텝 - ecommerce 카테고리 og:image 생산자 신설, page og:description 死키 정정 - sirsoft-basic 1.1.2 og 바인딩 정정, admin_basic 1.0.7 SEO 탭 업로더(+ja 팩 2종) - 검수 중 발견한 text 모드 오캐시 결함은 실패 테스트 선행 후 수정
This commit is contained in:
1 parent
14eb2e39e4
commit
1ba67ca7cf
98 files changed
+4640
-101
No files matched your search
@@ -112,4 +112,96 @@ class PostResourceThumbnailUrlTest extends BoardTestCase
|
||||
$response['thumbnail'],
|
||||
);
|
||||
}
|
||||
|
||||
// ── 본문 첫 내부 이미지 캐시 폴백 (공개 이슈 #22) ──────────────
|
||||
|
||||
/**
|
||||
* 이미지 첨부가 없으면 본문 캐시(content_thumbnail_url)로 폴백해야 합니다.
|
||||
*
|
||||
* @scenario image_source=content_internal_only, secrecy=normal
|
||||
*
|
||||
* @effects content_internal_image_fills_list_thumbnail
|
||||
*/
|
||||
#[Test]
|
||||
public function thumbnail_falls_back_to_content_cache_without_attachment(): void
|
||||
{
|
||||
$postId = $this->createTestPost([
|
||||
'content' => '<img src="/storage/uploads/content.jpg">',
|
||||
'content_thumbnail_url' => '/storage/uploads/content.jpg',
|
||||
]);
|
||||
|
||||
$post = Post::with(['thumbnailAttachment', 'board'])->findOrFail($postId);
|
||||
|
||||
$response = (new PostResource($post))->toArray(Request::create('/'));
|
||||
|
||||
$this->assertSame('/storage/uploads/content.jpg', $response['thumbnail']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 이미지 첨부와 본문 캐시가 모두 있으면 첨부가 우선해야 합니다 (첨부 우선 정책).
|
||||
*
|
||||
* @scenario image_source=both, secrecy=normal
|
||||
*
|
||||
* @effects attachment_takes_precedence_over_content_image
|
||||
*/
|
||||
#[Test]
|
||||
public function attachment_takes_precedence_over_content_cache(): void
|
||||
{
|
||||
['post' => $post, 'attachment' => $attachment] = $this->createPostWithAttachment('image/jpeg', [
|
||||
'content_thumbnail_url' => '/storage/uploads/content.jpg',
|
||||
]);
|
||||
|
||||
$response = (new PostResource($post))->toArray(Request::create('/'));
|
||||
|
||||
$this->assertSame(
|
||||
'/api/modules/sirsoft-board/boards/'.$this->board->slug.'/attachment/'.$attachment->hash.'/preview',
|
||||
$response['thumbnail'],
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 비밀글은 본문 캐시가 있어도 썸네일이 null 이어야 합니다.
|
||||
*
|
||||
* 에디터 이미지는 공개 hash 서빙이라 첨부와 달리 서빙측 차단이 없다 —
|
||||
* 이 게이트가 유일한 차단선이므로 폴백은 반드시 게이트 뒤에 있어야 한다.
|
||||
*
|
||||
* @scenario image_source=content_internal_only, secrecy=secret_unauthorized
|
||||
*
|
||||
* @effects secret_post_thumbnail_stays_null
|
||||
*/
|
||||
#[Test]
|
||||
public function secret_post_thumbnail_null_even_with_content_cache(): void
|
||||
{
|
||||
$postId = $this->createTestPost([
|
||||
'is_secret' => true,
|
||||
'content' => '<img src="/storage/uploads/secret.jpg">',
|
||||
'content_thumbnail_url' => '/storage/uploads/secret.jpg',
|
||||
]);
|
||||
|
||||
$post = Post::with(['thumbnailAttachment', 'board'])->findOrFail($postId);
|
||||
|
||||
$response = (new PostResource($post))->toArray(Request::create('/'));
|
||||
|
||||
$this->assertArrayHasKey('thumbnail', $response);
|
||||
$this->assertNull($response['thumbnail'], '비밀글은 본문 캐시 URL 도 방출되지 않아야 합니다.');
|
||||
}
|
||||
|
||||
/**
|
||||
* 첨부도 본문 캐시도 없으면 null 이어야 합니다.
|
||||
*
|
||||
* @scenario image_source=none, secrecy=normal
|
||||
*
|
||||
* @effects external_only_content_yields_null
|
||||
*/
|
||||
#[Test]
|
||||
public function thumbnail_is_null_without_attachment_and_cache(): void
|
||||
{
|
||||
$postId = $this->createTestPost(['content' => '<p>이미지 없음</p>']);
|
||||
|
||||
$post = Post::with(['thumbnailAttachment', 'board'])->findOrFail($postId);
|
||||
|
||||
$response = (new PostResource($post))->toArray(Request::create('/'));
|
||||
|
||||
$this->assertNull($response['thumbnail']);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user