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

IBX-6620: Added image search criterions #284

Merged
merged 13 commits into from
Nov 20, 2023

Conversation

ciastektk
Copy link
Contributor

@ciastektk ciastektk commented Oct 12, 2023

Question Answer
JIRA issue IBX-6620
Type feature
Target Ibexa version v4.6
BC breaks no

Requires:
ibexa/solr#55
https://github.com/ibexa/elasticsearch/pull/29
ibexa/rest#76

This PR adds new criteria that allows to search images.

Examples:

FileSize criterion:

Criterion to filter by image size.

min_size - Minimum file size in MB
max_size - Maximum file size in MB

new FileSize(string $fieldDefIdentifier, int $minFileSize = 0, ?int $maxFileSize = null);

Width criterion:

Criterion to filter by image width.

min_value - Minimum file size in pixels
max_value - Maximum file size in pixels

new Width(string $fieldDefIdentifier, int $minValue = 0, ?int $maxValue = null);

Height criterion:

Criterion to filter by image height.

min_value - Minimum file size in pixels
max_value - Maximum file size in pixels

new Height(string $fieldDefIdentifier, int $minValue = 0, ?int $maxValue = null);

MimeType criterion:

Criterion to filter by image mime type.

type - string or array, e.g.: image/png

new MimeType(string $fieldDefIdentifier, $type);

Orientation criterion:

Criterion to filter by image orientation.

orientation - string or array. Allowed orientation types: portrait, landscape, square.

new Orientation(string $fieldDefIdentifier, $orientation);

Dimensions criterion:

Composite criterion to filter by image dimensions.

data - allowed criteria width, height. All criteria are optional.

$data = [
    'width' => [
        'min' => 0 // (default: 0, optional),
        'max' => 1000 // (default: null, optional),
    ],
    'height' => [
        'min' => 0 // (default: 0, optional),
        'max' => 1000 // (default: null, optional),
    ],
]

new Dimensions(string $fieldDefIdentifier, array $data);

Image criterion:

Composite criterion to filter by image attributes.

data - allowed criteria mimeTypes, size,width, height,orientation. All criteria are optional.

$data = [
    'mimeTypes' => [
       'image/png'
    ],
    'orientation' => [
       'image/png'
    ],
    'width' => [
        'min' => 0 // (default: 0, optional),
        'max' => 1000 // (default: null, optional),
    ],
    'height' => [
        'min' => 0 // (default: 0, optional),
        'max' => 1000 // (default: null, optional),
    ],
    'size' => [
        'min' => 0 // (default: 0, optional),
        'max' => 2 // (default: null, optional),
    ],
];

or 

$data = [
    'mimeTypes' => 'image/png',
    'orientation' => 'image/png',
    'width' => [
        'min' => 0 // (default: 0, optional),
        'max' => 1000 // (default: null, optional),
    ],
    'height' => [
        'min' => 0 // (default: 0, optional),
        'max' => 1000 // (default: null, optional),
    ],
    'size' => [
        'min' => 0 // (default: 0, optional),
        'max' => 2 // (default: null, optional),
    ],
];

new Image(string $fieldDefIdentifier, array $data);

Checklist:

  • Provided PR description.
  • Tested the solution manually.
  • Provided automated test coverage.
  • Checked that target branch is set correctly (main for features, the oldest supported for bugs).
  • Ran PHP CS Fixer for new PHP code (use $ composer fix-cs).
  • Asked for a review (ping @ibexa/engineering).

@ciastektk ciastektk force-pushed the ibx-6620-added-image-search-criterions branch 3 times, most recently from ab4cf7f to f8d8834 Compare October 18, 2023 09:32
@ciastektk ciastektk force-pushed the ibx-6620-added-image-search-criterions branch 17 times, most recently from 9d43358 to e161218 Compare October 26, 2023 12:26
@ciastektk ciastektk force-pushed the ibx-6620-added-image-search-criterions branch from e161218 to 5840b37 Compare October 27, 2023 10:08
@ciastektk ciastektk force-pushed the ibx-6620-added-image-search-criterions branch 2 times, most recently from 61af225 to f5ee9c8 Compare November 3, 2023 12:01
@ciastektk ciastektk marked this pull request as ready for review November 3, 2023 12:36
@ciastektk ciastektk added Feature New feature request Ready for review labels Nov 3, 2023
@ciastektk ciastektk force-pushed the ibx-6620-added-image-search-criterions branch from f5ee9c8 to 94d4e03 Compare November 6, 2023 12:22
@ciastektk ciastektk requested a review from a team November 7, 2023 14:01
@ciastektk ciastektk requested a review from a team November 9, 2023 09:12
Co-authored-by: Dawid Parafiński <dawid.parafinski@ez.no>
@ciastektk ciastektk force-pushed the ibx-6620-added-image-search-criterions branch from 18ccfb8 to e012b49 Compare November 9, 2023 10:01
@ciastektk ciastektk force-pushed the ibx-6620-added-image-search-criterions branch from e012b49 to 07d16be Compare November 9, 2023 10:58
@ciastektk ciastektk force-pushed the ibx-6620-added-image-search-criterions branch from 25d2284 to 2320f67 Compare November 13, 2023 07:27
Copy link

sonarcloud bot commented Nov 13, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 5 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@ciastektk ciastektk added Doc needed The changes require some documentation Ready for QA and removed Ready for review labels Nov 13, 2023
@webhdx webhdx merged commit e88368c into main Nov 20, 2023
24 checks passed
@webhdx webhdx deleted the ibx-6620-added-image-search-criterions branch November 20, 2023 14:18
@juskora juskora removed the Doc needed The changes require some documentation label Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New feature request Ready for QA
Projects
None yet
7 participants