Skip to content

Commit

Permalink
Add possibily to use banner video
Browse files Browse the repository at this point in the history
  • Loading branch information
thomlamb committed Mar 25, 2020
1 parent 284243e commit 6e81448
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
4 changes: 4 additions & 0 deletions cpskin/core/viewlets/banner.pt
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,8 @@
tal:attributes="src view/getImageBannerUrl"
i18n:attributes="alt" />

<video autoplay muted loop id="banner-video">
<source tal:attributes="src view/getImageBannerUrl" src="" type="video/mp4" > </source>
</video>

</div>
20 changes: 19 additions & 1 deletion cpskin/core/viewlets/banner.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,12 @@ def isInPortalMode(self):
return IInPortal.providedBy(request)

def getUnscaleUrl(self, obj, fieldname, scale):
if obj is None:
if 'obj' is None:
return ''
if fieldname in ('video'):
print (fieldname + 'Sous-chaîne trouvée')
banner_url = obj.absolute_url()
return banner_url
if has_crop(obj, fieldname, scale):
view = obj.restrictedTraverse('@@images')
scale = view.scale(fieldname, scale=scale)
Expand All @@ -118,11 +122,25 @@ def getBanner(self):
local_banner = getattr(context.aq_explicit, 'banner.jpg', None)
banner_folder = getattr(context, 'banner', None)
banner = getattr(context, 'banner.jpg', None)
banner_video_folder = getattr(context, 'banner-video', None)
if context.portal_type == 'Event' and local_banner_event:
return {
'object': context,
'url': self.getUnscaleUrl(context, 'image_banner', 'banner'),
}
if banner_video_folder and (not local_banner and not local_banner_folder ):
banner_folder_to_use = banner_video_folder
brains = api.content.find(
context=banner_folder_to_use,
portal_type='File',
)
if brains:
brain = brains[random.randrange(len(brains))]
obj = brain.getObject()
return {
'object': obj,
'url': self.getUnscaleUrl(obj, 'video', 'banner'),
}
if local_banner_folder or (banner_folder and not local_banner):
banner_folder_to_use = local_banner_folder and local_banner_folder or banner_folder
brains = api.content.find(
Expand Down
9 changes: 9 additions & 0 deletions cpskin/core/vocabulary.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,15 @@ def __call__(self, context, query=None):
'show-image': True,
'show-carousel': False,
},
u'slider-count-bottom-text': {
'value': u'slider-count-bottom-text',
'title': _(u'slider count bottom text'),
'slider': True,
'class': 'slider-count-bottom-text',
'control-nav': True,
'show-image': True,
'show-carousel': False,
},
}

items = [(disp['value'], disp['title']) for disp in DISPLAY_TYPES.values()]
Expand Down

0 comments on commit 6e81448

Please sign in to comment.