image: hmmm, why there are not loading

This commit is contained in:
ZhymabekRoman 2025-01-25 11:54:50 +05:00
parent 13ab8edce2
commit 5e60190bc1
2 changed files with 25 additions and 8 deletions

View file

@ -361,7 +361,7 @@ class MediumParser:
out_paragraphs.append(header_template_rendered)
elif paragraph["type"] == "IMG":
image_template = jinja_env.from_string(
'<div class="mt-7"><img alt="{{ paragraph.metadata.alt }}" class="pt-5 m-auto lazy" role="presentation" referrerpolicy="no-referrer" data-src="https://miro.medium.com/v2/resize:fit:700/{{ paragraph.metadata.id }}"></div>'
'<div class="mt-7"><img alt="{{ paragraph.metadata.alt }}" class="pt-5 m-auto" role="presentation" referrerpolicy="no-referrer" src="https://miro.medium.com/v2/resize:fit:700/{{ paragraph.metadata.id }}"></div>'
)
image_caption_template = jinja_env.from_string(
"<figcaption class='mt-3 text-sm text-center text-gray-500 dark:text-gray-200'>{{ text }}</figcaption>"
@ -529,9 +529,26 @@ class MediumParser:
out_paragraphs.append(pq_template_rendered)
elif paragraph["type"] == "MIXTAPE_EMBED":
# TODO: redirect all Medium embeding articles to Fredium
embed_template = jinja_env.from_string(
'<div class="items-center p-2 overflow-hidden border border-gray-300 mt-7"><a rel="noopener follow" href="{{ url }}" target="_blank"> <div class="flex flex-row justify-between p-2 overflow-hidden"><div class="flex flex-col justify-center p-2"><h2 class="text-base font-bold text-black dark:text-gray-100">{{ embed_title }}</h2><div class="block mt-2"><h3 class="text-sm text-grey-darker">{{ embed_description }}</h3></div><div class="mt-5"><p class="text-xs text-grey-darker">{{ embed_site }}</p></div></div><div class="relative flex h-40 flew-row w-60"><div class="absolute inset-0 bg-center bg-cover lazy" referrerpolicy="no-referrer" data-bg="https://miro.medium.com/v2/resize:fit:320/{{ paragraph.mixtapeMetadata.thumbnailImageId }}"></div></div></div> </a></div>'
)
mixtape_embed_html = """
<div class="items-center p-2 overflow-hidden border border-gray-300 mt-7">
<a rel="noopener follow" href="{{ url }}" target="_blank">
<div class="flex flex-row justify-between p-2 overflow-hidden">
<div class="flex flex-col justify-center p-2">
<h2 class="text-base font-bold text-black dark:text-gray-100">{{ embed_title }}</h2>
<div class="block mt-2">
<h3 class="text-sm text-grey-darker">{{ embed_description }}</h3>
</div>
<div class="mt-5">
<p class="text-xs text-grey-darker">{{ embed_site }}</p>
</div>
</div>
<div class="relative flex h-40 flew-row w-60">
<div class="absolute inset-0 bg-center bg-cover" style="background-image: url('https://miro.medium.com/v2/resize:fit:320/{{ paragraph.mixtapeMetadata.thumbnailImageId }}'); background-repeat: no-repeat;" referrerpolicy="no-referrer"></div>
</div>
</div>
</a>
</div>"""
embed_template = jinja_env.from_string(mixtape_embed_html)
if paragraph.get("mixtapeMetadata") is not None:
url = paragraph["mixtapeMetadata"]["href"]
else:
@ -585,7 +602,7 @@ class MediumParser:
out_paragraphs.append(embed_template_rendered)
elif paragraph["type"] == "IFRAME":
iframe_template = jinja_env.from_string(
'<div class="mt-7"><iframe class="w-full lazy" data-src="{{ host_address }}/render_iframe/{{ iframe_id }}" allowfullscreen="" frameborder="0" scrolling="no"></iframe></div>'
'<div class="mt-7"><iframe class="w-full" src="{{ host_address }}/render_iframe/{{ iframe_id }}" referrerpolicy="no-referrer" allowfullscreen="" frameborder="0" scrolling="no"></iframe></div>'
)
iframe_template_rendered = iframe_template.render(
host_address=self.host_address,

View file

@ -27,7 +27,7 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css">
<script src="https://cdn.jsdelivr.net/npm/@iframe-resizer/parent"></script>
<script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload@17.8.4/dist/lazyload.min.js"></script>
<!-- <script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload@17.8.4/dist/lazyload.min.js"></script> -->
<script src="https://cdn.jsdelivr.net/npm/lightense-images@1.0.17/dist/lightense.min.js"></script>
<script>iframeResize({ license: 'GPLv3' })</script>
@ -347,7 +347,7 @@
Lightense('img:not(.no-lightense)');
}, false);
</script>
<script>
<!-- <script>
var lazyLoadInstance = new LazyLoad({
callback_loaded: function (element) {
console.log(element);
@ -382,7 +382,7 @@
}
}
});
</script>
</script> -->
<script>
function navigateToOrigin() {
window.location.href = window.location.origin;