Fix card image priority: own > mined from article > inherited
The resolved (inheriting) Node.image was checked before mining the article, so a front-page banner image shadowed the articles' own extracted figures everywhere: card covers, og:image and the editor's card previews.
This commit is contained in:
@@ -74,7 +74,8 @@ const image = ref('')
|
||||
const imageResolved = ref('')
|
||||
const imageSource = ref('')
|
||||
// The image the server would mine from the article itself — the card
|
||||
// previews fall back to it when no node image resolves (mirrors og:image).
|
||||
// previews fall back to it when the node has no image of its own, and it
|
||||
// beats an inherited one (mirrors og:image).
|
||||
const imageMined = ref('')
|
||||
// Whether the page has children (from the doc message): an own share
|
||||
// image is inherited by the whole section.
|
||||
@@ -86,22 +87,25 @@ const imageLabel = computed(() => {
|
||||
? `card image: set for this article — used in /${path.value}/*`
|
||||
: 'card image: set for this article'
|
||||
}
|
||||
if (imageMined.value) return 'card image: from the article'
|
||||
if (imageResolved.value) {
|
||||
const where = imageSource.value === '' ? 'the front page' : `/${imageSource.value}`
|
||||
return `card image: inherited from ${where}`
|
||||
}
|
||||
if (imageMined.value) return 'card image: from the article'
|
||||
return 'card image: none'
|
||||
})
|
||||
// The page title and description (from the doc message) feed the mock card
|
||||
// previews; empty shows placeholder bars / text instead.
|
||||
const pageTitle = ref('')
|
||||
const pageDesc = ref('')
|
||||
// The image the Twitter cards preview with: the resolved node card image,
|
||||
// else the mined article image (what og:image would use). image_resolved is
|
||||
// a bare store hash; image_mined is already a src path.
|
||||
// The image the Twitter cards preview with: the node's own card image,
|
||||
// else the mined article image, else the inherited node image (what
|
||||
// og:image would use). image/image_resolved are bare store hashes;
|
||||
// image_mined is already a src path.
|
||||
const cardImage = computed(() =>
|
||||
imageResolved.value ? `/_f/${imageResolved.value}` : imageMined.value,
|
||||
image.value
|
||||
? `/_f/${image.value}`
|
||||
: imageMined.value || (imageResolved.value ? `/_f/${imageResolved.value}` : ''),
|
||||
)
|
||||
// Card-mode override (Node.large, per-article, NOT inherited):
|
||||
// null = automatic, false = small, true = large.
|
||||
|
||||
Reference in New Issue
Block a user