<s> from __future__ import absolute_import , unicode_literals <EOL> from wagtail . wagtailimages . formats import get_image_format <EOL> from wagtail . wagtailimages . models import get_image_model <EOL> class ImageEmbedHandler ( object ) : <EOL> """<STR_LIT>""" <EOL> @ staticmethod <EOL> def get_db_attributes ( tag ) : <EOL> """<STR_LIT>""" <EOL> return { <EOL> '<STR_LIT:id>' : tag [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : tag [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : tag [ '<STR_LIT>' ] , <EOL> } <EOL> @ staticmethod <EOL> def expand_db_attributes ( attrs , for_editor ) : <EOL> """<STR_LIT>""" <EOL> Image = get_image_model ( ) <EOL> try : <EOL> image = Image . objects . get ( id = attrs [ '<STR_LIT:id>' ] ) <EOL> except Image . DoesNotExist : <EOL> return "<STR_LIT>" <EOL> image_format = get_image_format ( attrs [ '<STR_LIT>' ] ) <EOL> if for_editor : <EOL> return image_format . image_to_editor_html ( image , attrs [ '<STR_LIT>' ] ) <EOL> else : <EOL> return image_format . image_to_html ( image , attrs [ '<STR_LIT>' ] ) </s>
