diff --git a/README.md b/README.md index 31d0cb9..a5b6f8a 100644 --- a/README.md +++ b/README.md @@ -123,9 +123,9 @@ Available options for the `ImageType`: - `max_height` (`int`): the max height of the cropped image send to server (default: `180`) - `preview_width` (`string`): the max width to use when displaying the image preview - can be in px, % or other css value (default: `'320px'`) - `preview_height` (`string`): the max height to use when displaying the image preview - can be in px, % or other css value (default: `'180px'`) -- `upload_button_class` (`string`): class of the button (default: `''`) -- `cancel_button_class` (`string`): class of the button (default: `''`) -- `save_button_class` (`string`): class of the button (default: `''`) +- `upload_button_class` (`string`): CSS class of the "upload" button (default: `''`) +- `cancel_button_class` (`string`): CSS class of the "cancel" button (default: `''`) +- `save_button_class` (`string`): CSS class of the "save" button (default: `''`) - `download_uri` (`string`): the path where the image is located (default: `null`, automatically set) - `show_image` (`bool`): whether the image should be rendered in the form or not (default: `null`, will default to `true` in next major) - ~~`download_link` (`bool`): whether the image should be rendered in the form or not (default: `true`)~~ **Deprecated, will be removed (replaced by `show_image`) in next major** diff --git a/src/Form/Type/ImageType.php b/src/Form/Type/ImageType.php index 29aabd5..dd723b4 100644 --- a/src/Form/Type/ImageType.php +++ b/src/Form/Type/ImageType.php @@ -83,15 +83,19 @@ public function configureOptions(OptionsResolver $resolver): void ] ) ->setAllowedTypes('aspect_ratios', ['array']) + ->setInfo('aspect_ratios', 'A list of aspect ratio to apply when resizing an image.') ->setDefault('cropper_options', ['autoCropArea' => 1]) ->setAllowedTypes('cropper_options', ['array']) + ->setInfo('cropper_options', 'A list of options supported by cropper.') ->setDefault('max_width', 320) ->setAllowedTypes('max_width', ['int']) + ->setInfo('max_width', 'The max width of the cropped image send to server.') ->setDefault('max_height', 180) ->setAllowedTypes('max_height', ['int']) + ->setInfo('max_height', 'The max height of the cropped image send to server.') ->setDefault( 'preview_width', @@ -102,6 +106,10 @@ static function (Options $options): string { } ) ->setAllowedTypes('preview_width', ['string']) + ->setInfo( + 'preview_width', + 'The max width to use when displaying the image preview. Can be in px, % or other css value.' + ) ->setDefault( 'preview_height', @@ -112,24 +120,34 @@ static function (Options $options): string { } ) ->setAllowedTypes('preview_height', ['string']) + ->setInfo( + 'preview_height', + 'The max height to use when displaying the image preview. Can be in px, % or other css value.' + ) ->setDefault('upload_button_class', '') ->setAllowedTypes('upload_button_class', ['string']) + ->setInfo('upload_button_class', 'CSS class of the "upload" button.') ->setDefault('cancel_button_class', '') ->setAllowedTypes('cancel_button_class', ['string']) + ->setInfo('cancel_button_class', 'CSS class of the "cancel" button.') ->setDefault('save_button_class', '') ->setAllowedTypes('save_button_class', ['string']) + ->setInfo('save_button_class', 'CSS class of the "save" button.') ->setDefault('download_uri', null) ->setAllowedTypes('download_uri', ['string', 'null']) + ->setInfo('download_uri', 'The path where the image is located.') ->setDefault('show_image', null) ->setAllowedTypes('show_image', ['bool', 'null']) + ->setInfo('show_image', 'Whether the image should be rendered in the form or not.') ->setDefault('download_link', true) ->setAllowedTypes('download_link', ['bool']) + ->setInfo('download_link', 'Whether the image should be rendered in the form or not.') ->setDeprecated( 'download_link', 'presta/image-bundle', @@ -139,22 +157,31 @@ static function (Options $options): string { ->setDefault('file_upload_enabled', true) ->setAllowedTypes('file_upload_enabled', ['bool']) + ->setInfo('file_upload_enabled', 'Whether to enable the file upload widget or not.') ->setDefault('remote_url_enabled', true) ->setAllowedTypes('remote_url_enabled', ['bool']) + ->setInfo('remote_url_enabled', 'Whether to enable the remote url widget or not.') ->setDefault('rotation_enabled', false) ->setAllowedTypes('rotation_enabled', ['bool']) + ->setInfo('rotation_enabled', 'Whether to enable the rotation or not.') ->setDefault('translation_domain', 'PrestaImageBundle') ->setAllowedTypes('translation_domain', ['string']) ->setDefault('upload_mimetype', 'image/png') ->setAllowedTypes('upload_mimetype', ['string']) + ->setInfo( + 'upload_mimetype', + 'Format of the image to be uploaded. Note: If the chosen mimetype is not supported by the browser, ' + . 'it will silently fall back to `image/png`.' + ) // default value: https://developer.mozilla.org/de/docs/Web/API/HTMLCanvasElement/toDataURL ->setDefault('upload_quality', 0.92) ->setAllowedTypes('upload_quality', ['float']) + ->setInfo('upload_quality', 'Quality (0..1) of uploaded image for lossy imageformats (eg. `image/jpeg`).') ->setDefault('error_bubbling', false) ->setAllowedTypes('error_bubbling', ['bool'])