feat: add image resize percent

This commit is contained in:
Damillora 2022-04-15 04:19:05 +07:00
parent 2c56336c4f
commit 31763528bf
3 changed files with 13 additions and 5 deletions

View File

@ -56,7 +56,7 @@
<strong>Original:</strong>
</div>
<div class="row">
<a href={post.image_path}>Image</a>
<a href={post.image_path} target="_blank">Image</a>
</div>
</div>
<div class="panel-block column">

View File

@ -26,7 +26,7 @@
<strong>Original:</strong>
</div>
<div class="row">
<a href={post.image_path}>Image</a>
<a href={post.image_path} target="_blank">Image</a>
</div>
</div>
<div class="panel-block column">

View File

@ -40,6 +40,13 @@
const toggleEditMenu = () => {
editMenuShown = !editMenuShown;
};
let imagePercentage = "0%";
$: {
if (post)
imagePercentage = ((1000 * 100) / post.width).toFixed(0) + "%";
}
</script>
{#if post}
@ -82,8 +89,10 @@
<div class="column box">
{#if post.width > 1000}
<div class="notification is-info">
The image has been resized due to size. The original
image link is in the sidebar
Resized to {imagePercentage} of the original image.
<a href={post.image_path} target="_blank"
>View original</a
>
</div>
<figure class="image">
<img alt={post.id} src={post.preview_path} />
@ -97,5 +106,4 @@
</div>
</section>
</div>
{/if}