优化图片加载时的显示
This commit is contained in:
@@ -65,6 +65,13 @@
|
|||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ext-img__warpper.loading {
|
||||||
|
min-height: 100px;
|
||||||
|
background: url('/static/loading.gif') center no-repeat;
|
||||||
|
background-size: 25px 25px;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
.left-container .img-link img {
|
.left-container .img-link img {
|
||||||
max-height: 500px;
|
max-height: 500px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,6 +77,10 @@ function normalize_url(url) {
|
|||||||
return /^https?:\/\//.test(url) ? url : 'http://' + url;
|
return /^https?:\/\//.test(url) ? url : 'http://' + url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function stop_loading(e) {
|
||||||
|
e.target.parentNode.classList.remove('loading');
|
||||||
|
}
|
||||||
|
|
||||||
// props: text, show_pid, color_picker, search_param
|
// props: text, show_pid, color_picker, search_param
|
||||||
export class HighlightedMarkdown extends Component {
|
export class HighlightedMarkdown extends Component {
|
||||||
render() {
|
render() {
|
||||||
@@ -96,12 +100,16 @@ export class HighlightedMarkdown extends Component {
|
|||||||
shouldProcessNode: (node) => node.name === 'img',
|
shouldProcessNode: (node) => node.name === 'img',
|
||||||
processNode(node, index) {
|
processNode(node, index) {
|
||||||
return (
|
return (
|
||||||
<img
|
<span className="ext-img__warpper loading">
|
||||||
src={normalize_url(node.attribs.src)}
|
<img
|
||||||
alt={node.alt}
|
src={normalize_url(node.attribs.src)}
|
||||||
className="ext-img"
|
alt={node.alt}
|
||||||
referrerPolicy="no-referrer"
|
className="ext-img"
|
||||||
/>
|
referrerPolicy="no-referrer"
|
||||||
|
onError={stop_loading}
|
||||||
|
onLoad={stop_loading}
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user