アニメーションを自動再生しないオプション (#4131)
* Refactor * settings * Media Proxy * Replace API response
This commit is contained in:
20
src/misc/wrap-url.ts
Normal file
20
src/misc/wrap-url.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import { URL } from 'url';
|
||||
import config from '../config';
|
||||
|
||||
/**
|
||||
* avatar, thumbnail, custom-emoji 等のURLをクライアント設定等によって置き換える
|
||||
*/
|
||||
export default function(url: string, me: any) {
|
||||
if (url == null) return url;
|
||||
|
||||
// アニメーション再生無効
|
||||
if (me && me.clientSettings && me.clientSettings.doNotAutoplayAnimation) {
|
||||
const u = new URL(url);
|
||||
const dummy = `${u.host}${u.pathname}`; // 拡張子がないとキャッシュしてくれないCDNがあるので
|
||||
let result = `${config.url}/proxy/${dummy}?url=${encodeURI(u.href)}`;
|
||||
result += '&static=1';
|
||||
return result;
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
Reference in New Issue
Block a user