def register_image_feature(features): formats.unregister_image_format('fullwidth') formats.unregister_image_format('left') formats.unregister_image_format('right') formats.register_image_format( formats.Format('fullwidth', _('Full width'), 'richtext-image full-width', 'max-1600x800')) formats.register_image_format( formats.Format('left', _('Left-aligned'), 'richtext-image left', 'max-1000x500')) formats.register_image_format( formats.Format('right', _('Right-aligned'), 'richtext-image right', 'max-1000x500'))
from wagtail.images.formats import Format, register_image_format, unregister_image_format unregister_image_format('fullwidth') unregister_image_format('left') unregister_image_format('right') register_image_format( Format('fullwidth', 'Full width', 'richtext-image img-responsive full-width', 'width-400')) register_image_format( Format('left', 'Left-aligned', 'richtext-image img-responsive left', 'width-200')) register_image_format( Format('right', 'Right-aligned', 'richtext-image img-responsive right', 'width-200'))
# image_formats.py from wagtail.images.formats import Format, unregister_image_format, register_image_format unregister_image_format('fullwidth') register_image_format( Format('fullwidth', 'Fullwidth', 'richtext-image fullwidth', 'max-1200x1200'))
from wagtail.images.formats import ( Format, register_image_format, unregister_image_format, ) unregister_image_format("fullwidth") unregister_image_format("left") unregister_image_format("right") register_image_format( Format("left", "Left-aligned", "richtext-image format-left", "width-300")) register_image_format( Format("right", "Right-aligned", "richtext-image format-right", "width-300")) register_image_format( Format("center", "Center-aligned", "richtext-image format-center", "width-300"))
except SourceImageIOError: # Image file is (probably) missing from /media/original_images - generate a dummy # rendition so that we just output a broken image, rather than crashing out completely # during rendering Rendition = image.renditions.model # pick up any custom Image / Rendition classes that may be in use half_rendition = Rendition(image=image, width=0, height=0) half_rendition.file.name = 'not-found' if self.classnames: class_attr = 'class="%s" ' % escape(self.classnames) else: class_attr = '' sizes = "(max-width: 480px) 512w, 100vw" srcset = "%s 512w, %s" % (escape( half_rendition.url), escape(rendition.url)) return ('<img %s%s ' 'width="%d" height="%d" ' 'alt="%s" srcset="%s" sizes="%s">') % ( extra_attributes, class_attr, rendition.width, rendition.height, alt_text, srcset, sizes) register_image_format( Format('halfwidth', 'Half Width (512px)', 'richtext-image half-width', 'max-512x410')) unregister_image_format("fullwidth") register_image_format( FullWidthImgFormat('fullwidth', 'Full width', 'richtext-image full-width', 'max-1400x1120'))