plone - 防止用户将 BMP、TIFF 等图像上传到 Plone 中的 ImageField

标签 plone archetypes dexterity

用户这样做是因为他们可以。

但是,图像自动调整大小等故障。

这让我成为一个悲伤的男孩。

如何在全站范围内将图像上传限制为 GIF、PNG 和 JPEG?

  • 对于原型(prototype)
  • 为灵巧
  • 最佳答案

    使用 Archetypes,您可以覆盖图像内容类或使用以下架构创建您自己的自定义图像内容类。

    您只需添加该行

    allowable_content_types = ('image/gif', 'image/jpeg', 'image/png'),
    

    到您的架构

    IE
    MyImageSchema = schemata.ATContentTypeSchema.copy() + atapi.Schema((
            ImageField('image',
                required = False,
                allowable_content_types = ('image/gif', 'image/jpeg', 'image/png'),
                storage=AttributeStorage(),
                sizes= {'large'   : (768, 768),
                       'preview' : (400, 400),
                       'mini'    : (200, 200),
                       'thumb'   : (128, 128),
                       'tile'    :  (64, 64),
                       'icon'    :  (32, 32),
                       'listing' :  (16, 16),
                      },
              widget = ImageWidget(
                         label=_(u"Image"),
                         show_content_type=False,
                 ),
        ),
    

    我可能会使用模式扩展器来扩展 Image 类,覆盖该特定字段

    http://weblion.psu.edu/services/documentation/developing-for-plone/products-from-scratch/schemaextender

    关于plone - 防止用户将 BMP、TIFF 等图像上传到 Plone 中的 ImageField,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9127630/

    相关文章:

    plone - 自定义小部件与词汇相关的错误

    Plone 的 portal_catalog(portal_type ="File") 没有返回我在 ZMI portal_catalog 页面中看到的所有对象

    maven - 使用 Maven 原型(prototype)时​​如何使用 artifactId 重命名目录?

    python - 如何在 BrowserView 中以 'edit' 模式呈现 Archetypes 小部件?

    jquery-ui - Plone Dexterity RelationChoice 小部件与 jQueryUI 冲突?

    plone - 从 "add link"对话中看不到新的敏捷内容类型

    drop-down-menu - Plone 5 中的 webcouturier.dropdownmenu

    plone - 对 Diazo 主题和 ZCML 资源目录使用相同的文件夹

    plone - 禁用未找到页面上的自动建议

    java - 关于如何创建新的 Maven 原型(prototype)的任何好的高级指南?