Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
flask-admin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Python-Dev
flask-admin
Commits
7a35ce85
Commit
7a35ce85
authored
Aug 07, 2013
by
Serge S. Koval
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved ImageUploadField URL generation logic
parent
4d9e1c3c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
2 deletions
+15
-2
upload.py
flask_admin/form/upload.py
+15
-2
No files found.
flask_admin/form/upload.py
View file @
7a35ce85
...
@@ -96,7 +96,14 @@ class ImageUploadInput(object):
...
@@ -96,7 +96,14 @@ class ImageUploadInput(object):
def
get_url
(
self
,
field
):
def
get_url
(
self
,
field
):
if
field
.
thumbnail_size
:
if
field
.
thumbnail_size
:
return
url_for
(
field
.
endpoint
,
filename
=
field
.
thumbnail_fn
(
field
.
data
))
filename
=
field
.
thumbnail_fn
(
field
.
data
)
else
:
filename
=
field
.
data
if
field
.
url_relative_path
:
filename
=
urljoin
(
field
.
url_relative_path
,
filename
)
return
url_for
(
field
.
endpoint
,
filename
)
return
url_for
(
field
.
endpoint
,
filename
=
field
.
data
)
return
url_for
(
field
.
endpoint
,
filename
=
field
.
data
)
...
@@ -248,7 +255,7 @@ class ImageUploadField(FileUploadField):
...
@@ -248,7 +255,7 @@ class ImageUploadField(FileUploadField):
namegen
=
None
,
allowed_extensions
=
None
,
namegen
=
None
,
allowed_extensions
=
None
,
max_size
=
None
,
max_size
=
None
,
thumbgen
=
None
,
thumbnail_size
=
None
,
thumbgen
=
None
,
thumbnail_size
=
None
,
endpoint
=
'static'
,
url_relative_path
=
None
,
endpoint
=
'static'
,
**
kwargs
):
**
kwargs
):
"""
"""
Constructor.
Constructor.
...
@@ -303,6 +310,12 @@ class ImageUploadField(FileUploadField):
...
@@ -303,6 +310,12 @@ class ImageUploadField(FileUploadField):
Width and height is in pixels. If `force` is set to `True`, will try to fit image into dimensions and
Width and height is in pixels. If `force` is set to `True`, will try to fit image into dimensions and
keep aspect ratio, otherwise will just resize to target size.
keep aspect ratio, otherwise will just resize to target size.
:param url_relative_path:
Relative path from the root of the static directory URL. Only gets used when generating
preview image URLs.
For example, your model might store just file names (`relative_path` set to `None`), but
`base_path` is pointing to subdirectory.
:param endpoint:
:param endpoint:
Static endpoint for images. Used by widget to display previews. Defaults to 'static'.
Static endpoint for images. Used by widget to display previews. Defaults to 'static'.
"""
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment