PageBuilder Field Auto Resize Images

The field type PageBuilderFieldImage extends the default file field type and adds Resize options.

When you create PageBuilder Add-ons and authorize the Upload of images it can be handy to set a Max width and Max Height for the image files.

When a user uploads an 8 megapixel image to a web site you can fix the size to 600px width and the PageBuilderFieldImage will automatically resize the image to 600px using the GD library.

In the WebIDE when adding a field you will find this field type as: PB Image Upload

Example of Registry Source:

  <rfield name="my_image">
    <rdata type="fieldtype">PageBuilderFieldImage</rdata>
    <rdata type="label">My Image</rdata>
    <rdata type="max_width">600</rdata>
    <rdata type="max_height">450</rdata>
    <rdata type="showpicture">1</rdata>
    <rdata type="picture">images/</rdata>
    <rdata type="overwrite">yes</rdata>
  </rfield>

Field Type options

  • if the uploaded picture is bigger than max_width or max_height it will resize accordingly.
  • overwrite if an image with the same name already exists on the server it will be overwritten.
  • picture is the path where the image files are uploaded. (required).