https://github.com/zerc/sorl_hacks
Some hacks for sorl.thumbnail
https://github.com/zerc/sorl_hacks
Last synced: 6 months ago
JSON representation
Some hacks for sorl.thumbnail
- Host: GitHub
- URL: https://github.com/zerc/sorl_hacks
- Owner: zerc
- License: mit
- Created: 2014-08-30T19:34:31.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-09-03T20:22:43.000Z (over 11 years ago)
- Last Synced: 2025-07-28T08:14:14.762Z (7 months ago)
- Language: Python
- Size: 172 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG
- License: LICENSE
Awesome Lists containing this project
README
==================
django-sorl-hacks
==================
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 %}
{{ text_block }}
{{ text_block.body|create_thumbs|safe }}
{% endfor %}
ThumbedCkeditorImages
---------------------
Admin model mixin with post_save replacing.
admin.py:
.. code:: python
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 %}
{% empty %}
{% endthumbnail %}
**INSTALL**
Your ``models.py``:
.. code:: python
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)