Skip to content

Commit 7d2d24d

Browse files
feat: added pictures align features
Signed-off-by: eknath.baravkar <[email protected]>
1 parent 6a649db commit 7d2d24d

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

djangocms_picture/cms_plugins.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,15 @@ class PicturePlugin(CMSPluginBase):
5454
]
5555

5656
def get_render_template(self, context, instance, placeholder):
57-
return 'djangocms_picture/{}/picture.html'.format(instance.template)
57+
return 'djangocms_picture/{}/picture.html'.format(instance.template)
5858

5959
def render(self, context, instance, placeholder):
6060
if instance.alignment:
6161
# See https://getbootstrap.com/docs/5.2/content/images/#aligning-images
6262
if instance.alignment != "center":
6363
instance.add_classes(f"float-{instance.alignment}")
6464
else:
65-
instance.add_classes("mx-auto d-block")
66-
65+
instance.add_classes("mx-auto d-block")
6766
classes = 'align-{} '.format(instance.alignment)
6867
classes += instance.attributes.get('class', '')
6968
# Set the class attribute to include the alignment html class
@@ -76,8 +75,6 @@ def render(self, context, instance, placeholder):
7675
height=context.get('height') or 0,
7776
)
7877
context['img_srcset_data'] = instance.img_srcset_data
79-
8078
return super().render(context, instance, placeholder)
81-
82-
79+
8380
plugin_pool.register_plugin(PicturePlugin)

djangocms_picture/models.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
from filer.fields.image import FilerImageField
1515
from filer.models import ThumbnailOption
1616

17-
1817
# add setting for picture alignment, renders a class or inline styles
1918
# depending on your template setup
2019
def get_alignment():
@@ -50,7 +49,6 @@ def get_templates():
5049
)
5150
return choices
5251

53-
5452
# use golden ration as default (https://en.wikipedia.org/wiki/Golden_ratio)
5553
PICTURE_RATIO = getattr(settings, 'DJANGOCMS_PICTURE_RATIO', 1.6180)
5654

@@ -188,7 +186,6 @@ class AbstractPicture(CMSPlugin):
188186
default=False,
189187
help_text=_('Crops the image according to the thumbnail settings provided in the template.'),
190188
)
191-
192189
use_upscale = models.BooleanField(
193190
verbose_name=_('Upscale image'),
194191
blank=True,
@@ -215,7 +212,6 @@ class AbstractPicture(CMSPlugin):
215212
help_text=_('Overrides width, height, and crop; scales up to the provided preset dimensions.'),
216213
on_delete=models.CASCADE,
217214
)
218-
219215
# Add an app namespace to related_name to avoid field name clashes
220216
# with any other plugins that have a field with the same name as the
221217
# lowercase of the class name of this model.

0 commit comments

Comments
 (0)