Question

Photo of Daniel Hazelbaker

0

File Uploader in Block Settings

Okay, so I have a block that is going to include a URL to an image in an XML feed. I want the user (administrator) to be able to select what image. BinaryFileField seemed like the way to go. But it only lets you select an existing image, not upload a new one. Digging through the source code I came up with this. It seems to work but I'm not sure if I am just missing the correct way to do it (or is this it), and I'm not sure if it is safe to do so:

[BinaryFileField( Rock.SystemGuid.BinaryFiletype.MEDIA_FILE, "About Us Category Image", "The image to use for the about us category.", false, category: "About Us", order: 3, FieldTypeClass = "Rock.Field.Types.ImageFieldType" )]

  • Photo of David Turner

    0

    Daniel, That is a clever work-around. Typically we have an Attribute class for each of the field types (so that you don't need to change the FieldTypeClass of another attribute class like you did), but it appears we don't have one for the ImageFieldType or FileFieldType classes.  So for now, that would be a viable work around and is safe to do.  In future we will probably add attribute classes for those field types so you could use [ImageField(...)] and not have to override the FieldTypeClass.

    • Nick Airdo

      Daniel, we'll also happily accept a pull request if you want to add those ImageFieldTypeAttribute and FileFieldTypeAttribute classes (if you're up to coding them.)