Skip to main content

create_thumbs template tag

Parse your text on fly, finds images urls and replace it by thumb url:

{% load sorl_hacks %}

{% for text_block in post.blocks.all %}
    <h4>{{ text_block }}</h4>
    <p>{{ text_block.body|create_thumbs|safe }}</p>
    <hr>
{% endfor %}

ThumbedCkeditorImages

Admin model mixin with post_save replacing.

admin.py:

from sorl_hacks.admin import ThumbedCkeditorImages

class BlogPostAdmin(ThumbedCkeditorImages):
    ...

ThumbMixin

Usefull in stadart Django templates. Add property my_model.get_thumb_WIDTHxHEIGHT to yours models.

Example of my_model_detail.html:

{{ my_model.get_thumb_200x200.html }}

{{ my_model.get_thumb_small.html }}

instead of:

{% thumbnail my_model.pic "56x56" crop="center" as im %}
    <img src="{{ im.url }}" width="56" height="56">
{% empty %}
    <img src="{{ MISSING_IMAGE }}" width="56" height="56">
{% endthumbnail %}

INSTALL

Your models.py:

from django.db import models
from sorl.thumbnail import ImageField
from sorl_hacks.models import ThumbMixin

class Post(ThumbMixin, models.Model):
    image = ImageField('image', upload_to='posts', **nullable)

Metadata

Release files for django-sorl-hacks 0.1.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-sorl-hacks 0.1.10
File Size Uploaded Provenance Actions
django-sorl-hacks-0.1.10.tar.gz 4.9 kB Without provenance Details for django-sorl-hacks-0.1.10.tar.gz

Release files / django-sorl-hacks-0.1.10.tar.gz

Download URL django-sorl-hacks-0.1.10.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
760b6a6e897b37bd44c8abe6de2bf1adc27fd29d4bfed1cc385593fa895c155e
BLAKE2b-256 checksum
How to use checksums
94000b79fa00dca97113f7b6bfb4be0d25aab192507f0650f9be2c6af3b28633
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for django-sorl-hacks 0.1.10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.10 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page