Skip to content

Commit

Permalink
Merge pull request #65 from plone/allow-easier-customization
Browse files Browse the repository at this point in the history
Allow easier customizations
  • Loading branch information
jensens authored Jun 24, 2019
2 parents 5cb83ff + 0a81116 commit 55a9f0a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions news/65.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
It is now possible to customize in an easier way the ``@@images`` view [ale-rt]
13 changes: 9 additions & 4 deletions plone/namedfile/scaling.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ class ImageScaling(BrowserView):
# Ignore some stacks to help with accessing via webdav, otherwise you get a
# 404 NotFound error.
_ignored_stacks = ('manage_DAVget', 'manage_FTPget')
_scale_view_class = ImageScale

def publishTraverse(self, request, name):
""" used for traversal via publisher, i.e. when using as a url """
Expand All @@ -302,15 +303,19 @@ def publishTraverse(self, request, name):
info = storage.get(name)
if info is None:
raise NotFound(self, name, self.request)
scale_view = ImageScale(self.context, self.request, **info)
scale_view = self._scale_view_class(
self.context,
self.request,
**info
)
alsoProvides(scale_view, IStableImageScale)
return scale_view
else:
# otherwise `name` must refer to a field...
if '.' in name:
name, ext = name.rsplit('.', 1)
value = getattr(self.context, name)
scale_view = ImageScale(
scale_view = self._scale_view_class(
self.context,
self.request,
data=value,
Expand All @@ -324,7 +329,7 @@ def traverse(self, name, furtherPath):
# validate access
value = self.guarded_orig_image(name)
if not furtherPath:
image = ImageScale(
image = self._scale_view_class(
self.context,
self.request,
data=value,
Expand Down Expand Up @@ -446,7 +451,7 @@ def scale(
**parameters
)
info['fieldname'] = fieldname
scale_view = ImageScale(self.context, self.request, **info)
scale_view = self._scale_view_class(self.context, self.request, **info)
return scale_view

def calculate_srcset(
Expand Down

0 comments on commit 55a9f0a

Please sign in to comment.