~cadence/bibliogram

4363891fa69e2593fbec99b3b9e0f2bba377b84b — Cadence Ember 3 months ago 1ea2e2e
Add configuration option to disable media proxy

Media proxy is enabled by default, and was always enabled before this
commit.
M src/lib/constants.js => src/lib/constants.js +5 -0
@@ 41,6 41,11 @@ let constants = {
	does_not_track: false,

	allow_user_from_reel: "fallback", // one of: "never", "fallback", "prefer", "onlyPreferSaved", "preferForRSS"
	proxy_media: { // Whether to proxy media (images, videos, thumbnails) through Bibliogram. This is strongly recommended to protect user privacy. If proxy is turned off, some browser content blockers may break all images since they are served from Facebook domains.
		image: true,
		video: true,
		thumbnail: true
	},

	feeds: {
		// Whether feeds are enabled.

M src/lib/structures/TimelineBaseMethods.js => src/lib/structures/TimelineBaseMethods.js +6 -2
@@ 26,11 26,15 @@ class TimelineBaseMethods {
	}

	getDisplayUrlP() {
		return proxyImage(this.data.display_url)
		let url = this.data.display_url
		if (constants.proxy_media.image) url = proxyImage(url)
		return url
	}

	getVideoUrlP() {
		return proxyVideo(this.data.video_url)
		let url = this.data.video_url
		if (constants.proxy_media.video) url = proxyVideo(url)
		return url
	}

	getAlt() {

M src/lib/structures/TimelineEntry.js => src/lib/structures/TimelineEntry.js +9 -3
@@ 154,7 154,9 @@ class TimelineEntry extends TimelineBaseMethods {
	getThumbnailSrcsetP() {
		if (this.data.thumbnail_resources) {
			return this.data.thumbnail_resources.map(tr => {
				return `${proxyImage(tr.src, tr.config_width)} ${tr.config_width}w`
				let src = tr.src
				if (constants.proxy_media.thumbnail) src = proxyImage(tr.src, tr.config_width)
				return `${src} ${tr.config_width}w`
			}).join(", ")
		} else {
			return null


@@ 174,16 176,20 @@ class TimelineEntry extends TimelineBaseMethods {
				found = tr
				if (tr.config_width >= size) break // don't proceed once we find one large enough
			}
			let src = found.src
			if (constants.proxy_media.thumbnail) src = proxyImage(src, found.config_width) // force resize to config rather than requested
			return {
				config_width: found.config_width,
				config_height: found.config_height,
				src: proxyImage(found.src, found.config_width) // force resize to config rather than requested
				src
			}
		} else if (this.data.thumbnail_src) {
			let src = this.data.thumbnail_src
			if (constants.proxy_media.thumbnail) src = proxyImage(src, size) // force resize to requested
			return {
				config_width: size, // probably?
				config_height: size,
				src: proxyImage(this.data.thumbnail_src, size) // force resize to requested
				src
			}
		} else {
			return null