Skip to content

Commit

Permalink
Added image search criteria (#2225)
Browse files Browse the repository at this point in the history
  • Loading branch information
juskora authored Mar 27, 2024
1 parent e68085b commit 7b018c3
Show file tree
Hide file tree
Showing 9 changed files with 444 additions and 0 deletions.
121 changes: 121 additions & 0 deletions docs/search/criteria_reference/image_criterion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
---
description: Image Criterion
---

# Image Criterion

The `Image` Search Criterion searches for image by specified image attributes.

## Arguments

- `fieldDefIdentifier` - string representing the identifier of the Field
- `imageCriteriaData` - array representing image attributes. All attributes are optional.

## Example

### PHP

``` php
$imageCriteriaData = [
'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)
],
];
$query->query = new Criterion\Image('image', $imageCriteriaData);
```

### REST API

=== "XML"

```xml
<Query>
<Filter>
<ImageCriterion>
<fieldDefIdentifier>image</fieldDefIdentifier>
<mimeTypes>image/png</mimeTypes>
<size>
<min>0</min>
<max>2</max>
</size>
<width>
<min>100</min>
<max>1000</max>
</width>
<height>
<min>500</min>
<max>1500</max>
</height>
<orientation>portrait</orientation>
</ImageCriterion>
</Filter>
</Query>
```

=== "JSON"

```json
"Query": {
"Filter": {
"ImageCriterion": {
"fieldDefIdentifier": "image",
"mimeTypes": "image/png",
"size": {
"max": 1.5
},
"width": {
"max": 1000
},
"height": {
"max": 1500
},
"orientation": "portrait"
}
}
}

OR

"Query": {
"Filter": {
"ImageCriterion": {
"fieldDefIdentifier": "image",
"mimeTypes": [
"image/png",
"image/jpeg"
],
"size": {
"min": 0,
"max": 2
},
"width": {
"min": 100,
"max": 1000
},
"height": {
"min": 500,
"max": 1500
},
"orientation": [
"portrait",
"landscape"
]
}
}
}
```
73 changes: 73 additions & 0 deletions docs/search/criteria_reference/imagedimensions_criterion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
description: Image Dimensions Criterion
---

# Image Dimension Criterion

The `Dimensions` Search Criterion searches for image with specified dimensions.

## Arguments

- `fieldDefIdentifier` - string representing the identifier of the Field
- `imageCriteriaData` - an array representing minimum and maximum values for width and height, expressed in pixels

## Example

### PHP

``` php
$imageCriteriaData = [
'width' => [
'min' => 100, // (default: 0, optional)
'max' => 1000, // (default: null, optional)
],
'height' => [
'min' => 500, // (default: 0, optional)
'max' => 1500, // (default: null, optional)
],
];

$query->query = new Criterion\Dimensions('image', $imageCriteriaData);
```

### REST API

=== "XML"

```xml
<Query>
<Filter>
<ImageDimensionsCriterion>
<fieldDefIdentifier>image</fieldDefIdentifier>
<width>
<min>100</min>
<max>1000</max>
</width>
<height>
<min>500</min>
<max>1500</max>
</height>
</ImageDimensionsCriterion>
</Filter>
</Query>
```

=== "JSON"

```json
"Query": {
"Filter": {
"ImageDimensionsCriterion": {
"fieldDefIdentifier": "image",
"width": {
"min": 100,
"max": 1000
},
"height": {
"min": 500,
"max": 1500
}
}
}
}
```
55 changes: 55 additions & 0 deletions docs/search/criteria_reference/imagefilesize_criterion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
description: Image FileSize Criterion
---

# Image FileSize Criterion

The `FileSize` Search Criterion searches for image with specified size.

## Arguments

- `fieldDefIdentifier` - string representing the identifier of the Field
- (optional) `minValue` - numeric representing minimum file size expressed in MB, default: 0
- (optional) `maxValue` - numeric representing maximum file size expressed in MB, default: `null`

## Example

### PHP

``` php
$query->query = new Criterion\FileSize('image', 0, 1.5);
```

### REST API

=== "XML"

```xml
<Query>
<Filter>
<ImageFileSizeCriterion>
<fieldDefIdentifier>image</fieldDefIdentifier>
<size>
<min>0</min>
<max>1.5</max>
</size>
</ImageFileSizeCriterion>
</Filter>
</Query>
```

=== "JSON"

```json
"Query": {
"Filter": {
"ImageFileSizeCriterion":{
"fieldDefIdentifier": "image",
"size": {
"min": 0,
"max": 1.5
}
}
}
}
```
21 changes: 21 additions & 0 deletions docs/search/criteria_reference/imageheight_criterion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
description: Image Height Criterion
---

# Image Height Criterion

The `Height` Search Criterion searches for image with specified height.

## Arguments

- `fieldDefIdentifier` - string representing the identifier of the Field
- (optional) `minValue` - int representing minimum file height expressed in pixels, default: 0
- (optional) `maxValue` - int representing maximum file height expressed in pixels, default: `null`

## Example

### PHP

``` php
$query->query = new Criterion\Height('image', 0, 1500);
```
70 changes: 70 additions & 0 deletions docs/search/criteria_reference/imagemimetype_criterion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
description: Image MimeType Criterion
---

# Image MimeType Criterion

The `MimeType` Search Criterion searches for image with specified mime type(s).

## Arguments

- `fielDefIdentifier` - string representing the identifier of the Field
- `type` - string(s) representing mime type(s)

## Example

### PHP

``` php
$query->query = new Criterion\MimeType('image', 'image/jpeg');
```

or

```php
$mimeTypes = [
'image/jpeg',
'image/png',
];

$query->query = new Criterion\MimeType('image', $mimeTypes);
```

### REST API

=== "XML"

```xml
<Query>
<Filter>
<ImageMimeTypeCriterion>
<fieldDefIdentifier>image</fieldDefIdentifier>
<type>image/png</type>
</ImageMimeTypeCriterion>
</Filter>
</Query>
```

=== "JSON"

```json
"Query": {
"Filter": {
"ImageMimeTypeCriterion": {
"fieldDefIdentifier": "image",
"type": "image/png"
}
}
}

OR

"Query": {
"Filter": {
"ImageMimeTypeCriterion": {
"fieldDefIdentifier": "image",
"type": ["image/png", "image/jpeg"]
}
}
}
```
Loading

0 comments on commit 7b018c3

Please sign in to comment.