Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

Commit

Permalink
Fixed bug with uploaded images from busy being broken
Browse files Browse the repository at this point in the history
A bug crept up with the images from posts uploaded to busy. The hosted IFPS files don't display. Adding steemitimages as a proxy to the URL fixed the issue.
  • Loading branch information
KrNel committed May 24, 2019
1 parent d2b05f8 commit ff3532e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
7 changes: 3 additions & 4 deletions client/src/components/pages/Steem/helpers/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@

import filesize from 'filesize';

const IMG_PROXY = 'https://steemitimages.com/0x0/';
//const IMG_PROXY = 'https://steemitimages.com/0x0/';
const IMG_PROXY = 'https://steemitimages.com/640x0/';
const IMG_PROXY_PREVIEW = 'https://steemitimages.com/600x800/';
const IMG_PROXY_SMALL = 'https://steemitimages.com/40x40/';

export const MAXIMUM_UPLOAD_SIZE = 15728640;
export const MAXIMUM_UPLOAD_SIZE_HUMAN = filesize(MAXIMUM_UPLOAD_SIZE);

export const getProxyImageURL = (url, type) => {
if (url.indexOf('https://ipfs.busy.org') === 0 || url.indexOf('https://gateway.ipfs.io') === 0) {
return url;
} else if (type === 'preview') {
if (type === 'preview') {
return `${IMG_PROXY_PREVIEW}${url}`;
} else if (type === 'small') {
return `${IMG_PROXY_SMALL}${url}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ function proxifyImages(doc) {
if (!doc) return;
Array.prototype.forEach.call(doc.getElementsByTagName('img'), node => {
const url = node.getAttribute('src');

if (!linksRe.local.test(url)) {// eslint-disable-line import/no-named-as-default-member
node.setAttribute('src', getProxyImageURL(url));
}
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/pages/Steem/helpers/steemitLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ const urlSet = ({ domain = domainPath, path } = {}) =>
*/
export const any = (flags = 'i') => new RegExp(urlSet(), flags);
export const local = (flags = 'i') =>
new RegExp(urlSet({ domain: '(?:localhost|(?:.*\\.)?steemit.com|(?:.*\\.)?busy.org)' }), flags);
new RegExp(urlSet({ domain: '(?:localhost|(?:.*\\.)?steemit.com)' }), flags);
export const remote = (flags = 'i') =>
new RegExp(
urlSet({ domain: `(?!localhost|(?:.*\\.)?steemit.com|(?:.*\\.)?busy.org)${domainPath}` }),
urlSet({ domain: `(?!localhost|(?:.*\\.)?steemit.com)${domainPath}` }),
flags,
);
export const youTube = (flags = 'i') =>
Expand Down

0 comments on commit ff3532e

Please sign in to comment.