Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7663873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:09:34+00:00 2026-05-31T14:09:34+00:00

The users do it because they can. However, image auto-resize etc. breaks down. This

  • 0

The users do it because they can.

However, image auto-resize etc. breaks down.

This make me a sad boy.

How to limit image uploads to GIF, PNG and JPEG sitewide?

  • For Archetypes

  • For Dexterity

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T14:09:35+00:00Added an answer on May 31, 2026 at 2:09 pm

    i ran into similar problems these days and worked around them like that:

    • add a custom widget that adds an accept attribute to the file input
    • set field.swallowResizeExceptions = True so users at least don’t get a site-error when uploading an unsopported image type
    • state mimetypes that work in description

    The field definition looks like this:

    atapi.ImageField('image1',
        swallowResizeExceptions = True,
        widget = atapi.ImageWidget(
            label = _(u"Image 1"),
            description = _(u"Image used in listings. (JPEG, PNG and GIF are supported)"),
            show_content_type = False,
            accept = 'image/*',
            macro = 'mywidgets/myimage',
            ),
        ),
    

    note that accept="image/jpeg,image/gif"was ignored by firefox11
    although it sould be supported according to http://www.w3schools.com/tags/att_input_accept.asp

    mywidgets/myimage is a customized version of archetypes/skins/widgets/image.pt that uses a customized version of archetypes/skins/widgets/file.pt

    <metal:define define-macro="edit">
    ...
       <metal metal:use-macro="here/mywidgets/myfile/macros/file_upload"/>
    ...
    

    and mywidgets/myfile.pt simply defines this macro:

    <metal:define define-macro="file_upload"
           tal:define="unit accessor;
                       size unit/get_size | python:unit and len(unit) or 0;">
        <input type="file"
               size="30"
               tal:attributes="name string:${fieldName}_file;
                               id string:${fieldName}_file;
                               accept widget/accept|nothing;" />
        <script type="text/javascript"
            tal:define="isDisabled python:test(accessor() and size!=0, 'true', 'false')"
                tal:content="string:document.getElementById('${fieldName}_file').disabled=$isDisabled;">
        </script>
    </metal:define>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Update Putting this at the top because it is crazy :) So some users
I have a page that shows statistics for users, this cannot be cached because
I keep getting duplicate entries in my database because of impatient users clicking the
We use an LDAP server to authenticate our users. Because the server is accessed
I want to redirect users to the SSL secure server when they are accessing
I'm using a pan gesture to move around an image. You touch down, drag,
I have a variety of users on my SQL server, all of which CAN
Part 1 I want to build a PHP Zend Framework application that users can
Thanks in advance for any assistance anyone can provide with this torturous issue. I
Our dovecot and email server authenticate users using SHA1 digests. We can't really change

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.