Creating image thumbnails using easy-thumbnails
You are displaying the original image on the detail page, but dimensions for different images may vary considerably. Also, the original files for some images may be huge, and loading them might take too long. The best way to display optimized images in a uniform way is to generate thumbnails. Let's use a Django application called easy-thumbnails
for this purpose.
Open the terminal and install easy-thumbnails
using the following command:
pip install easy-thumbnails==2.7
Edit the settings.py
file of the bookmarks project and add easy_thumbnails
to the INSTALLED_APPS
setting, as follows:
INSTALLED_APPS = [
# ...
'easy_thumbnails',
]
Then, run the following command to sync the application with your database:
python manage.py migrate
You should see an output that includes the following lines:
Applying easy_thumbnails.0001_initial... OK
Applying easy_thumbnails.0002_thumbnaildimensions...