Skip to content

Streams_Stream::metas(): fall back to Streams/icon sizes, not Streams/image - #37

Open
zattak1 wants to merge 1 commit into
Qbix:mainfrom
zattak1:upstream/fix-og-image-fallback
Open

Streams_Stream::metas(): fall back to Streams/icon sizes, not Streams/image#37
zattak1 wants to merge 1 commit into
Qbix:mainfrom
zattak1:upstream/fix-og-image-fallback

Conversation

@zattak1

@zattak1 zattak1 commented Aug 27, 2026

Copy link
Copy Markdown

Stream permalinks advertise an og:image / twitter:image that 404s, for every stream type that has no Q/images/<type> config of its own — which includes Streams/chat, so every conversation permalink is affected.

Cause

Streams_Stream::metas():

try {
    $sizes = Q_Image::getSizes($this->type, $maxStretch);
} catch (Exception $e) {
    $sizes = Q_Image::getSizes('Streams/image', $maxStretch);
}
$iconFile = end($sizes);

Q_Image::getSizes() opens with Q_Config::expect("Q","images",$type,'sizes'), which throws when the type has no images entry — so for Streams/chat the catch branch is not an edge case, it is the path every request takes.

The two size lists in Streams/config/plugin.json:

"Streams/icon":  { "sizes": ["40","50","80","1000"] }
"Streams/image": { "sizes": ["40","50","80","200x","x200","1000x"] }

end() gives 1000.jpg on the first and 1000x.jpg on the second. But the files are written by Streams::importIcon($publisherId, $streamName, $sources, $save = "Streams/icon", …) — the first list. So the writer and the reader name two different config keys, and the meta tag asks for a file that was never generated.

Observed on a live install: the advertised …/icon/<time>/1000x.jpg returns 404 while its sibling …/icon/<time>/1000.jpg returns 200 with the real image. 40, 50 and 80 resolve identically under either key, which is why every other use of the icon looks correct and only link previews break.

By contrast a type that does carry an images config (Calendars/event) takes the try branch and unfurls correctly — the symptom tracks the presence of a config entry, not the data.

Fix

Fall back to Streams/icon, the list importIcon() writes with, so reader and writer agree. One word, no behaviour change for any type that has its own images config.

Q_Image::getSizes() throws for any stream type with no Q/images/<type>
entry, which includes Streams/chat, so Streams_Stream::metas() takes its
catch branch for every conversation. That branch fell back to the
"Streams/image" size list, whose largest entry is "1000x" => "1000x.jpg".

Stream icons are written by Streams::importIcon(), whose $save default is
"Streams/icon", whose largest entry is "1000" => "1000.jpg". Reader and
writer were reading two different config keys one character apart, so
every conversation permalink advertised an og:image / twitter:image that
404ed while the real 1000.jpg sat beside it on disk.

Falling back to the writer's own default makes the two agree. Types that
DO have their own images config (Calendars/event) are unaffected -- they
never reach this branch, which is why event permalinks already unfurled
correctly and conversations did not.

Refs ro#388
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant