Update LinkThumbnailWidgetParams.ts
This commit is contained in:
parent
8702a38922
commit
aabb4302b0
|
@ -24,8 +24,9 @@ function getLocalOgData(url: string) {
|
||||||
|
|
||||||
async function saveLocalOgData(url:string, ogData: ogData) {
|
async function saveLocalOgData(url:string, ogData: ogData) {
|
||||||
const imgUrl = ogData.ogImage;
|
const imgUrl = ogData.ogImage;
|
||||||
|
if (imgUrl !== "") {
|
||||||
const lastDot = imgUrl.lastIndexOf(".");
|
const lastDot = imgUrl.lastIndexOf(".");
|
||||||
const imgType = imgUrl.substring(lastDot, imgUrl.length).toLowerCase();
|
let imgType = imgUrl.substring(lastDot + 1, imgUrl.length).toLowerCase();
|
||||||
|
|
||||||
const file = await requestUrl({url:imgUrl, contentType: `image/${imgType}`});
|
const file = await requestUrl({url:imgUrl, contentType: `image/${imgType}`});
|
||||||
const fileArrayBuffer = file.arrayBuffer;
|
const fileArrayBuffer = file.arrayBuffer;
|
||||||
|
@ -46,7 +47,9 @@ async function saveLocalOgData(url:string, ogData: ogData) {
|
||||||
const base64String = btoa(uint8.reduce((data, byte)=> {
|
const base64String = btoa(uint8.reduce((data, byte)=> {
|
||||||
return data + String.fromCharCode(byte);
|
return data + String.fromCharCode(byte);
|
||||||
}, ''));
|
}, ''));
|
||||||
|
if (imgType.includes("svg")) imgType += "+xml";
|
||||||
ogData.ogImage = `data:image/${imgType};charset=utf-8;base64,` + base64String;
|
ogData.ogImage = `data:image/${imgType};charset=utf-8;base64,` + base64String;
|
||||||
|
}
|
||||||
|
|
||||||
// 저장하기 전에 img 데이터를 url-> blob -> base64로 변환 후 저장
|
// 저장하기 전에 img 데이터를 url-> blob -> base64로 변환 후 저장
|
||||||
localStorage.setItem(OGDATACHACHE + url, JSON.stringify(ogData));
|
localStorage.setItem(OGDATACHACHE + url, JSON.stringify(ogData));
|
||||||
|
|
Loading…
Reference in New Issue