Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions lib/plugins/system/oembed/providers.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,6 @@
],
"endpoint": "https://graph.facebook.com/v24.0/oembed_post"
},
{
"name": "Facebook Page",
"templates": [
"(?:www|m)\\.facebook\\.com/(?:pg|pages)/",
"(?:www|m)\\.facebook\\.com/[^/]+/?(?:about|photos|videos|events|timeline|photos_stream)?/?(?:\\?[^/\\?]+)?$"
],
"endpoint": "https://graph.facebook.com/v24.0/oembed_page"
},
{
"name": "Instagram",
"templates": [
Expand Down
137 changes: 20 additions & 117 deletions plugins/domains/facebook.com/facebook.page.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const WATCH_RE = /^https?:\/\/www\.facebook\.com\/watch\/?\?(?:.+&)?v=(\d+)/i;

export default {

re: [
Expand All @@ -8,123 +6,28 @@ export default {
/^https?:\/\/(www|m)\.facebook\.com\/people\/[^\/]+\/\d+/i // for the "N/A" message only
],

mixins: [
"domain-icon",
"og-image",
"canonical",
"og-description",
"oembed-site",
"og-title"
// "fb-error" // Otherwise the HTTP redirect won't work for URLs like http://www.facebook.com/133065016766815_4376785445728063
],

getLinks: function(oembed, url, meta, options) {

if (WATCH_RE.test(URL)) return; // Sometimes, for live videos it seems, HTML parser does not redirect to /user/video/ID and leave at /watch/?v=

var html = oembed.html.replace(/connect\.facebook\.net\/\w{2}_\w{2}\/sdk\.js/i,
'connect.facebook.net/' + options.getProviderOptions('locale', 'en_US').replace('-', '_') + '/sdk.js');

var height = oembed.height;

html = options.getRequestOptions('facebook.show_posts', false)
? html.replace(/data\-show\-posts=\"(?:false|0)?\"/i, 'data-show-posts="true"')
: html.replace(/data\-show\-posts=\"(true|1)\"/i, 'data-show-posts="false"');

html = options.getRequestOptions('facebook.show_facepile', false)
? html.replace(/data\-show\-facepile=\"(?:false|0)?\"/i, 'data-show-facepile="true"')
: html.replace(/data\-show\-facepile=\"(true|1)\"/i, 'data-show-facepile="false"');

html = options.getRequestOptions('facebook.small_header', false)
? html.replace(/data\-small\-header=\"(?:false|0)?\"/i, 'data-small-header="true"')
: html.replace(/data\-small\-header=\"(true|1)\"/i, 'data-small-header="false"');

var opts = {
show_posts: {
label: 'Show recent posts',
value: /data\-show\-posts="(true|1)"/i.test(html)
},
show_facepile: {
label: 'Show profile photos when friends like this',
value: /data\-show\-facepile="(true|1)"/i.test(html)
},
small_header: {
label: 'Use the small header instead',
value: /data\-small\-header="(true|1)"/i.test(html)
}
};

if (options.getRequestOptions('facebook.show_posts')) {
height = options.getRequestOptions('facebook.height', height);

if (height < 70) {
height = 70
};

opts.height = {
label: CONFIG.L.height,
value: height,
placeholder: 'ex.: 500, in px'
};

html.replace(/data\-height\=\"(\d+)\"/i, '');
html = options.getRequestOptions('facebook.height', oembed.height)
? html.replace(/data\-small\-header=\"/i, 'data-height="' + height + '" data-small-header="')
: html.replace(/data\-height\=\"(\d+)\"/i, '');
} else if (/data\-small\-header="(true|1)"/i.test(html)){
height = 70;
} else {
height = 130;
}

return {
type: CONFIG.T.text_html,
rel: [CONFIG.R.app, CONFIG.R.ssl],
html: html,
options: opts,
height: height
};
},

getData: function(oembedError, url, meta, options) {

if (WATCH_RE.test(URL)) return;

// Detect individual profiles (returns oEmbedError 400 as of Feb 4, 2023)
// But fb://profile/ links are also used for pages like https://www.facebook.com/RhulFencing/, albeit no oEmbedError
if (meta.ld?.person
|| meta.al?.android?.url && /\/profile\//.test(meta.al.android.url)) {

return {
message: "Facebook profile pages of individual users are not embeddable."
};

// Detect unowned pages (returns oEmbedError 400 as of Feb 4, 2023)
// Ex.: https://www.facebook.com/pages/Art-Friend-the-Curve/199296263568281
} else if (/\/pages\//.test(meta.canonical || url)) {

return {
message: "Unowned Facebook Pages are not supported."
}
getData: function(options, cb) {

// https://developers.facebook.com/blog/post/2025/04/08/oembed-updates/
const msg = 'Facebook has retired automated page embeds on November 3, 2025.';

if (options.getProviderOptions('facebook.thumbnail', true)) {
return cb({
message: msg
// and fall back to generic
});
} else {
return {
message : "This page cannot be embedded."
}
return cb({
responseStatusCode: 415,
message: msg
// and do not fall back to generic
});
}
}

},

tests: [
"https://www.facebook.com/facebook",
"https://www.facebook.com/hlaskyjanalasaka?fref=nf",
// "https://www.facebook.com/pages/Art-Friend-the-Curve/199296263568281", // unowned
"https://www.facebook.com/RhulFencing/",
"https://www.facebook.com/caboreytours/",
{
noFeeds: true,
skipMethods: ['getData'],
skipMixins: ['og-image']
}
]
// "https://www.facebook.com/facebook",
// "https://www.facebook.com/hlaskyjanalasaka?fref=nf",
// "https://www.facebook.com/pages/Art-Friend-the-Curve/199296263568281", // unowned
// "https://www.facebook.com/RhulFencing/",
// "https://www.facebook.com/caboreytours/"
};