Skip to main content

django-snippet-image

The python package provides a django field for automatic generation of images for sharing in social networks.

django-snippet-image based on snippet-image package.

Installation

` pip3 install django-snippet-image `

Example

Use SnippetImageField:

from django.db.models import (
    Model,
    CharField,
    ImageField,
)
from django_snippet_image import SnippetImageField


class Statuses:
    DRAFT = 'draft'
    PUBLISH = 'publish'

    CHOICES = (
        (DRAFT, 'Draft'),
        (PUBLISH, 'Publish'),
    )


class ExampleModel(Model):
    text = CharField(
        max_length=200,
        verbose_name='Text for snippet image',
    )
    background = ImageField(
        verbose_name='Background for snippet image',
        blank=True,
        null=True,
    )
    snippet_image_field = SnippetImageField(
        verbose_name='Example snippet image field',
        null=True,
    )
    status = CharField(
        max_length=20,
        choices=Statuses.CHOICES,
    )

    # Methods for collect data for snippet image.

    def get_snippet_image_text(self, snippet_type):
        return self.text if snippet_type == 'default' and self.text else ''

    def get_snippet_image_background(self, snippet_type):
        if snippet_type == 'default' and self.background:
            return self.background.path

    def snippet_image_should_be_created(self):
        return self.status == Statuses.PUBLISH

    class Meta:
        verbose_name = 'example object'
        verbose_name_plural = 'example objects'

And use in template:

<meta property="og:image" content="{{ instance.snippet_image_field.url }}" />

Read more on home page.

Metadata

Release files for django-snippet-image 0.1.3

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-snippet-image 0.1.3
File Size Uploaded Provenance
django-snippet-image-0.1.3.tar.gz 5.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for django-snippet-image 0.1.3
File Interpreter ABI Platform
django_snippet_image-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 12.4 kB

Release files / django-snippet-image-0.1.3.tar.gz

Download URL django-snippet-image-0.1.3.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
b57bb861318a76814b3ddb4fed5df002f3debe01c5df81356ae1d778ef9fc84c
BLAKE2b-256 checksum
How to use checksums
0a100c2eaef676e90b31950ba1dd5e6dfb441577dec36f3a59308a610bcdd62a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/0.12.15 CPython/3.7.3 Linux/5.0.0-15-generic

Release files / django_snippet_image-0.1.3-py3-none-any.whl

Download URL django_snippet_image-0.1.3-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
73e03935f5d9b1ba0d29b9ab57a22162573c4380370b8abbdf276b265fbc75a2
BLAKE2b-256 checksum
How to use checksums
cc83e4c32ee55ed10ed128222cd9bd3e19280b46f6e86c13e4c299e3a2dfda20
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/0.12.15 CPython/3.7.3 Linux/5.0.0-15-generic

Security for django-snippet-image 0.1.3

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.

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