Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documented the detectCorrupted and corruptedMessage options #6433

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions reference/constraints/Image.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ of the documentation on this constraint.
| | - `allowSquare`_ |
| | - `allowLandscape`_ |
| | - `allowPortrait`_ |
| | - `detectCorrupted`_ |
| | - `mimeTypesMessage`_ |
| | - `sizeNotDetectedMessage`_ |
| | - `maxWidthMessage`_ |
Expand All @@ -35,6 +36,7 @@ of the documentation on this constraint.
| | - `allowSquareMessage`_ |
| | - `allowLandscapeMessage`_ |
| | - `allowPortraitMessage`_ |
| | - `corruptedMessage`_ |
| | - See :doc:`File </reference/constraints/File>` for inherited options |
+----------------+-----------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Image` |
Expand Down Expand Up @@ -311,6 +313,18 @@ allowPortrait

If this option is false, the image cannot be portrait oriented.

detectCorrupted
~~~~~~~~~~~~~~~

.. versionadded:: 3.1
The ``detectCorrupted`` option was introduced in Symfony 3.1.

**type**: ``boolean`` **default**: ``false``

If this option is true, the image contents are validated to ensure that the
image is not corrupted. This validation is done with PHP's :phpfunction:`imagecreatefromstring`
function, which requires the `PHP GD extension`_ to be enabled.

sizeNotDetectedMessage
~~~~~~~~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -392,4 +406,16 @@ Portrait oriented images are not allowed``

The error message if the image is portrait oriented and you set `allowPortrait`_ to ``false``.

corruptedMessage
~~~~~~~~~~~~~~~~

.. versionadded:: 3.1
The ``corruptedMessage`` option was introduced in Symfony 3.1.

**type**: ``string`` **default**: ``The image file is corrupted.``

The error message when the `detectCorrupted`_ option is enabled and the image
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was to unsure to commit this, but shouldn't we use if here instead of when?

is corrupted.

.. _`IANA website`: http://www.iana.org/assignments/media-types/image/index.html
.. _`PHP GD extension`: http://php.net/manual/en/book.image.php