Skip to content

Commit

Permalink
fix: working relative url for images
Browse files Browse the repository at this point in the history
  • Loading branch information
popstas committed May 14, 2022
1 parent 57ec1c4 commit ec85f7a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,12 @@ export default {
// show images as images
if (typeof valueText === 'string' && (field.type === 'image' || valueText.match(/^http.*\.(jpg|jpeg|png|gif)$/)) && valueText) {
// relative urls
if (valueText.startsWith('/') && row.url) {
const url = new URL(row.url);
valueText = `${url.origin}/${valueText}`;
}
valueText = `<img alt="error loading image" style="width: 150px; height: auto;" src="${valueText}" title="${valueText}"/>`;
}
Expand Down

0 comments on commit ec85f7a

Please sign in to comment.