Added image_{width,height,area} search syntax

This commit is contained in:
rr- 2016-02-19 09:44:46 +01:00
parent f7df1cb536
commit 2bba57e8de
3 changed files with 21 additions and 0 deletions

View file

@ -123,6 +123,9 @@
{search: 'date:2000-01-01', description: 'posted on January 1st, 2000'},
{search: 'id:1', description: 'having specific post ID'},
{search: 'name:<em>hash</em>', description: 'having specific post name (hash in full URLs)'},
{search: 'image_width:100..', description: 'being at least 100 pixels wide'},
{search: 'image_height:100..', description: 'being at least 100 pixels tall'},
{search: 'image_area:10000..', description: 'having at least 10000 pixels'},
{search: 'type:image', description: 'only image posts'},
{search: 'type:flash', description: 'only Flash posts'},
{search: 'type:youtube', description: 'only Youtube posts'},

View file

@ -35,6 +35,9 @@ class PostFilter extends BasicFilter implements IFilter
const REQUIREMENT_TYPE = 'posts.contentType';
const REQUIREMENT_USER_SCORE = 'posts.userScore';
const REQUIREMENT_TUMBLEWEED = 'tumbleweed';
const REQUIREMENT_IMAGE_WIDTH = 'posts.imageWidth';
const REQUIREMENT_IMAGE_HEIGHT = 'posts.imageHeight';
const REQUIREMENT_IMAGE_AREA = 'posts.imageWidth*posts.imageHeight';
public function __construct()
{

View file

@ -175,6 +175,21 @@ class PostSearchParserConfig extends AbstractSearchParserConfig
$requirement->setNegated($token->isNegated());
return $requirement;
});
$this->defineNamedTokenParser(
PostFilter::REQUIREMENT_IMAGE_WIDTH,
['image_width', 'posts'],
self::ALLOW_COMPOSITE | self::ALLOW_RANGE);
$this->defineNamedTokenParser(
PostFilter::REQUIREMENT_IMAGE_HEIGHT,
['image_height', 'posts'],
self::ALLOW_COMPOSITE | self::ALLOW_RANGE);
$this->defineNamedTokenParser(
PostFilter::REQUIREMENT_IMAGE_AREA,
['image_area', 'posts'],
self::ALLOW_COMPOSITE | self::ALLOW_RANGE);
}
public function createFilter()