src/pyams_file/skin/__init__.py
changeset 218 458cf3d033aa
parent 167 4760ae4610ac
child 219 1c07e0c889ba
equal deleted inserted replaced
217:48a990f311cb 218:458cf3d033aa
    33     embedding all image attributes.
    33     embedding all image attributes.
    34     """
    34     """
    35 
    35 
    36     def render(self, context=None, lg_thumb='lg', lg_width=12, md_thumb='md', md_width=12,
    36     def render(self, context=None, lg_thumb='lg', lg_width=12, md_thumb='md', md_width=12,
    37                sm_thumb='sm', sm_width=12, xs_thumb='xs', xs_width=12,
    37                sm_thumb='sm', sm_width=12, xs_thumb='xs', xs_width=12,
    38                def_thumb=None, def_width=None, alt='', css_class=''):
    38                def_thumb=None, def_width=None, alt='', css_class='', img_width='100%'):
    39         if context is None:
    39         if context is None:
    40             context = self.context
    40             context = self.context
    41         if context.content_type.startswith('image/svg'):
    41         if context.content_type.startswith('image/svg'):
    42             return render('templates/svg-picture.pt',
    42             return render('templates/svg-picture.pt', {
    43                           {'image': context,
    43                 'image': context,
    44                            'lg_width': lg_width,
    44                 'lg_width': lg_width,
    45                            'md_width': md_width,
    45                 'md_width': md_width,
    46                            'sm_width': sm_width,
    46                 'sm_width': sm_width,
    47                            'xs_width': xs_width,
    47                 'xs_width': xs_width,
    48                            'alt': alt,
    48                 'alt': alt,
    49                            'css_class': css_class},
    49                 'css_class': css_class,
    50                           request=self.request)
    50                 'img_width': img_width
       
    51             }, request=self.request)
    51         else:
    52         else:
    52             if def_thumb is None:
    53             if def_thumb is None:
    53                 def_thumb = md_thumb or lg_thumb or sm_thumb or xs_thumb
    54                 def_thumb = md_thumb or lg_thumb or sm_thumb or xs_thumb
    54             if def_width is None:
    55             if def_width is None:
    55                 def_width = md_width or lg_width or sm_width or xs_width
    56                 def_width = md_width or lg_width or sm_width or xs_width
    56             return render('templates/picture.pt',
    57             return render('templates/picture.pt', {
    57                           {'image': context,
    58                 'image': context,
    58                            'lg_thumb': lg_thumb,
    59                 'lg_thumb': lg_thumb,
    59                            'lg_width': lg_width,
    60                 'lg_width': lg_width,
    60                            'md_thumb': md_thumb,
    61                 'md_thumb': md_thumb,
    61                            'md_width': md_width,
    62                 'md_width': md_width,
    62                            'sm_thumb': sm_thumb,
    63                 'sm_thumb': sm_thumb,
    63                            'sm_width': sm_width,
    64                 'sm_width': sm_width,
    64                            'xs_thumb': xs_thumb,
    65                 'xs_thumb': xs_thumb,
    65                            'xs_width': xs_width,
    66                 'xs_width': xs_width,
    66                            'def_thumb': def_thumb,
    67                 'def_thumb': def_thumb,
    67                            'def_width': def_width,
    68                 'def_width': def_width,
    68                            'alt': alt,
    69                 'alt': alt,
    69                            'css_class': css_class},
    70                 'css_class': css_class,
    70                           request=self.request)
    71                 'img_width': img_width
       
    72             }, request=self.request)