bridgy-fed
bridgy-fed copied to clipboard
Rewrite Jetpack CDN image (URLs) since some instances don't load them
Posted a photo just now and it's not working. Forgot to include u-photo
first, but then I tried attaching it to the img
and then the surrounding a
and updated both times. No luck, shows a black rectangle with "Not available."
https://indieweb.social/@[email protected]/109984562159038607, BF log: https://fed.brid.gy/log?start_time=1678231601&key=https://snarfed.org/2023-03-07_49461&module=
If I click on it, it links to the image on my site ok though. The a
and img
are fetting federated inside content
, but Mastodon should be stripping the img
, so I doubt that's a problem.

Also older post with photos aren't working either: https://indieweb.social/@[email protected]/109729051822644849 , https://indieweb.social/@[email protected]/109677037763348328


The plot thickens. Evidently u-featured
works ok, this is just a u-photo
issue? Examples from www.jvt.me:
- successful u-featured post, original, BF log
- broken u-photo post, original, BF log
They're also broken on other instances, so it's not an indieweb.social thing. eg:
- https://tech.lgbt/@[email protected]/109934332609794103
- https://social.coop/@[email protected]/109934332537003851
- https://mastodon.social/@[email protected]/109934332471708539
Oddly gregorlove.com has two successful u-photo posts since then:
- 3/4 Mastodon post, original, BF log
- 3/13 Mastodon post, original, BF log
Pruned down JSON AS2 objects from five of these examples. The second and third bad ones make sense, they have no image
and their attachment
s aren't images. The first one though, my original example, looks identical to the two good ones except it's missing name
. Guess I'll try adding that? Not holding my breath.
bad, my original example:
{
"type": "Note",
"id": "https://fed.brid.gy/r/https://snarfed.org/2023-03-07_49461",
"image": {
"type": "Image",
"url": "https://i0.wp.com/snarfed.org/w/wp-content/uploads/2023/03/PXL_20230307_163518349-1.PANO_-scaled.jpg?ssl=1"
},
"attachment": [{
"type": "Image",
"url": "https://i0.wp.com/snarfed.org/w/wp-content/uploads/2023/03/PXL_20230307_163518349-1.PANO_-scaled.jpg?ssl=1"
}],
}
bad:
{
"type": "Note",
"id": "https://fed.brid.gy/r/https://www.jvt.me/mf2/2023/03/lerm1/",
"attachment": [{
"type": "Note",
"url": "https://twitter.com/juhuachai/status/1631458755480023041",
"content": "\u201coptimal posting times\u201d \u201cstagger your posts\u201d if you see me you see me. it\u2019s in gods hands and i am not praying"
}]
}
bad:
{
"type": "Note",
"id": "https://fed.brid.gy/r/https://gregorlove.com/2023/02/after-following-on-instagram/",
"attachment": [{
"type": "Note",
"url": "https://manenough.com/podcast/",
"name": "The Man Enough Podcast"
}]
}
good:
{
"type": "Note",
"id": "https://fed.brid.gy/r/https://gregorlove.com/2023/03/i-usually-tend-to/",
"image": {
"type": "Image",
"url": "https://gregorlove.com/site/assets/files/6398/pxl_20230304_234257890_portrait.2000x0-is.jpg",
"name": "recent selfie"
},
"attachment": [{
"type": "Image",
"url": "https://gregorlove.com/site/assets/files/6398/pxl_20230304_234257890_portrait.2000x0-is.jpg",
"name": "recent selfie"
}]
}
good:
{
"type": "Note",
"id": "https://fed.brid.gy/r/https://gregorlove.com/2023/03/foggy-downtown/",
"image": {
"type": "Image",
"url": "https://gregorlove.com/site/assets/files/6404/pxl_20230311_224353429.1500x0.jpg",
"name": "Downtown San Diego with fog obscuring the tops of some buildings"
},
"attachment": [{
"type": "Image",
"url": "https://gregorlove.com/site/assets/files/6404/pxl_20230311_224353429.1500x0.jpg",
"name": "Downtown San Diego with fog obscuring the tops of some buildings"
}]
}
Added name
to the original post's image
and attachment
. No dice. 🤷 https://indieweb.social/@[email protected]/109984562159038607
Oh man. I switched the image URLs from the Jetpack CDN to my site directly (snarfed.org), and that fixed it. Ugh, so that CDN is blocking Mastodon, or it's otherwise failing to fetch from it? Oh, sheesh, looks like it was just indieweb.social, the image wasn't broken on other instances, eg https://tech.lgbt/@[email protected]/109984559730340646.
I bet Reclaim Hosting is the culprit here. Ugh. https://github.com/snarfed/bridgy/issues/885
Also, the two other bad example posts were probably unrelated, I suspect Mastodon expected their attachment
s were images and choked on them?
Confirmed. I removed the attachment from one of them, and the broken image went away. https://indieweb.social/@[email protected]/109934332056357887
Oh and re https://github.com/snarfed/bridgy-fed/issues/439#issuecomment-1469040563, looks like indieweb.social is hosted on https://masto.host/, not Reclaim.
Looks like we started adding attachment
for Mastodon, initially discovered in https://github.com/snarfed/bridgy-fed/issues/33#issuecomment-440965618. Evidently they still use it:
https://github.com/mastodon/mastodon/blob/65669d3c5719e72000bf26849d0ee1eaec1f9d1b/app/lib/activitypub/activity/create.rb#L255-L282
One hacky fix here would be to auto detect WP Jetpack CDN URLs and rewrite them to the original URL. ~Unfortunate to need to do that only because Reclaim is blocking Jetpack's CDN though. (Along with what seems like half the internet.)~ (Reclaim is blocking half the internet, but evidently not the root cause here specifically.)
https://mastodon.art/ has the same problem, and they're also on masto.host.
Hrm, so does https://mastodon.social/ , and they're not on masto.host.
Haven't yet found anything relevant in https://github.com/mastodon/mastodon/issues
Found an interesting workaround here: leave the img
pointing to the CDN image, move the u-photo
to an <a>
wrapping it that points to the local (ie not CDN) image file.