working images in the database

This commit is contained in:
erik-sn committed 2020-09-25 02:56:54 -04:00
1 parent 997f550aab
commit 9e40fb8010
15 files changed
+157 -128

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
// this is a hack. We are saving images in the database as
// delimiter separated URLS, but most common delimiters (comma, pipe
// hash, etc.) are often found in URLS (even though it's not technically
// within specification). To get around this we have our own delimiter
// here we'll use to join and split these strings
export const IMAGE_DELIMITER = "||!||";
export function withValidImage(link, onSuccess) {
// only add the media if it's a valid URL
const image = new Image();
image.onload = onSuccess;
image.onerror = () => {
console.warn(`Invalid image submitted: ${link}`);
};
image.src = link;
}
-9
View File
@@ -1,9 +0,0 @@
export function withValidMedia(link, onSuccess) {
// only add the media if it's a valid URL
const image = new Image();
image.onload = onSuccess;
image.onerror = () => {
console.warn(`Invalid image submitted: ${link}`);
};
image.src = link;
}