Skip to main content

Adds an image plugin to django CMS

Project description

pypi build coverage

django CMS Picture is a plugin for django CMS that allows you to add images on your site.

preview.gif

Contribute to this project and win rewards

Because this is a an open-source project, we welcome everyone to get involved in the project and receive a reward for their contribution. Become part of a fantastic community and help us make django CMS the best CMS in the world.

We’ll be delighted to receive your feedback in the form of issues and pull requests. Before submitting your pull request, please review our contribution guidelines.

We’re grateful to all contributors who have helped create and maintain this package. Contributors are listed at the contributors section.

Documentation

See REQUIREMENTS in the setup.py file for additional dependencies:

python django djangocms

  • Django Filer 1.7 or higher

Make sure django-filer is installed and configured appropriately.

Installation

For a manual install:

  • run pip install djangocms-picture

  • add djangocms_picture to your INSTALLED_APPS

  • run python manage.py migrate djangocms_picture

Configuration

Note that the provided templates are very minimal by design. You are encouraged to adapt and override them to your project’s requirements.

This addon provides a default template for all instances. You can provide additional template choices by adding a DJANGOCMS_PICTURE_TEMPLATES setting:

DJANGOCMS_PICTURE_TEMPLATES = [
    ('background', _('Background image')),
]

You’ll need to create the background folder inside templates/djangocms_picture/ otherwise you will get a template does not exist error. You can do this by copying the default folder inside that directory and renaming it to background.

Another setting is DJANGOCMS_PICTURE_NESTING, which allows you to render an image as the background image of a container that also contains other content (text, icons and so on).

DJANGOCMS_PICTURE_NESTING = True

will enable this (the default is False). When set to True, you’ll be able to place additional plugins inside the picture plugin.

You can override alignment styles with DJANGOCMS_PICTURE_ALIGN, for example:

DJANGOCMS_PICTURE_ALIGN = [
    ('top', _('Top Aligned')),
]

This will generate a class prefixed with align-. The example above would produce a class="align-top". Adding a class key to the image attributes automatically merges the alignment with the attribute class.

You can enable responsive images technique by setting``DJANGOCMS_PICTURE_RESPONSIVE_IMAGES`` to True. In this case uploaded images will create thumbnails of different sizes according to DJANGOCMS_PICTURE_RESPONSIVE_IMAGES_VIEWPORT_BREAKPOINTS (which defaults to [576, 768, 992]) and browser will be responsible for choosing the best image to display (based upon the screen viewport).

You can use DJANGOCMS_PICTURE_RATIO to set the width/height ratio of images if these values are not set explicitly on the image:

DJANGOCMS_PICTURE_RATIO = 1.618

We use the golden ratio, approximately 1.618, as a default value for this.

When working out sizes for the image, the system will use the following values, of preference:

  • the width or height set in the Thumbnail options

  • Autoscale

  • the Width and Height

We recommend setting width or height values around a placeholder so when the plugin uses Autoscale it can discover them:

{% with 720 as width and 480 as height %}
    {% placeholder content %}
{% endwith %}

Further configuration can be achieved through the django Filer settings.

Running Tests

You can run tests by executing:

virtualenv env
source env/bin/activate
pip install -r test_requirements/base.txt
python setup.py test

Updating from cmsplugin-filer

Historically, cmsplugin-filer was used to create file, folder, image, link, teaser & video plugins on your django CMS projects. Now cmsplugin-filer has been archived, you can still migrate your old instances without having to copy them manually to the new djangocms-<file|picture|link|…> plugins.

There’s a third-party management command that supports your migration:

migrate_cmsplugin_filer.py

This management command is only a starting point. It has worked out of the box for some people, but we encourage you to read the code, understand what it does, and test it on a development environment before running it on your production server.

The management command is only configured to transfer your cmsplugin_link, cmsplugin_file, cmsplugin_folder and cmsplugin_image plugins to modern djangocms_* plugins. If you need to transfer other cmsplugin_* plugins, you’ll have to write your own code.

Alternatively you can use the deprecate_cmsplugin_filer app, which only adds a small migration that transfer the old cmsplugin-filer plugins instances to the new djangocms-<file|picture|link|…> plugins.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

djangocms-picture-4.1.1.tar.gz (67.8 kB view details)

Uploaded Source

Built Distribution

djangocms_picture-4.1.1-py3-none-any.whl (347.6 kB view details)

Uploaded Python 3

File details

Details for the file djangocms-picture-4.1.1.tar.gz.

File metadata

  • Download URL: djangocms-picture-4.1.1.tar.gz
  • Upload date:
  • Size: 67.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for djangocms-picture-4.1.1.tar.gz
Algorithm Hash digest
SHA256 29ffadc514bfa306ec1f2ebb145391b9b860c12ba001e2475dffb5fe1be5cac2
MD5 709c0c494216addfd7d4205819d53ff7
BLAKE2b-256 ef5ef919a910b640e9d22fd56b1537ebe8cb1b92dc01acfcb8e460a5aed84bdf

See more details on using hashes here.

File details

Details for the file djangocms_picture-4.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for djangocms_picture-4.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d5a568f7bbbed7f9af3c7eb4901ec95b94ccdbc16b3debf52ae98f2ec6920671
MD5 f8454348c173914db4ad8a258bc025e1
BLAKE2b-256 8c80e2baa53109272b856c87f5965eb4e29a4ddc7ff4f50bd3b13d12c762f31f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page