Coder Social home page Coder Social logo

image-validator's People

Contributors

ardakilic avatar awgv avatar carawang avatar cviebrock avatar djuki avatar garaiviktor avatar keyduq avatar mgoebelm avatar nwidart avatar php-cpm avatar saeedsajadi avatar scvaer avatar shonetow avatar utkuyildirim avatar willwashburn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

image-validator's Issues

Script Error on missing locale

Hi,

thanks for your cool laravel projects, i use 3 of them and they are great!

I stumbled on the problem that I configured two locales, that are not yet translated (like es and cn). Then the image validator kills the whole laravel app when registering the ImageValidationServiceProvider as a string is tried to be accessed as array

The problem lies in this line:
$translation = trans('image-validator::validation');
$this->app['validator']->extend($rule, 'Cviebrock\ImageValidator\ImageValidator@validate' . $method, $translation[$rule]);

=>The variable $translattion is then not an array (if no translations are found) but actually a string (as laravel will return the key in case no translation is present) and then trying to access $rule in the array results in a hard error.

But its very easy to fix for example like this (generating the rule via appending the $rule to the key to be looked up):
$translation = trans('image-validator::validation.'.$rule);
$this->app['validator']->extend($rule, 'Cviebrock\ImageValidator\ImageValidator@validate' . $method, $translation);

Thanks!

PHP version

This is not an issue but does this library needs php 5.4? Wouldn't it work with PHP 5.3?

Requires BCMath

Validator requires bcmath extension

"require": {
...
"ext-bcmath": "*"
...
},

Support ">" in image_aspect

/vendor/cviebrock/image-validator/src/ImageValidator.php line 118:

// JohnLui 2015-11-12 15:33:43
// support ">" in image_aspect
if (substr($parameters[0],0,1)=='>') {
    if ( bccomp(substr($parameters[0], 1), $image_aspect, 10) == -1 ) {
        return true;
    }
}

How to show the language based dynamic error message?

My image width and heights are dynamic. We are using two types of language. How to show the language based dynamic error message?

Example:
$rules = [
'category_image' => 'image_size:250,300',//250 and 300 are dynamic value.
];

Error messages only in one language

Hi i'm doing a multi lang app and when i get an message error it only appears in the default locale of app/config/app.php , any ideia how i can show the error message with the app::getLocale ?

Issue with laravel 5.2

Hello @cviebrock

Please check with laravel version 5.2

I got this error within form request when I try to upload.

BadMethodCallException in Validator.php line 3255:
Method [validateImageSize] does not exist.

Thanks

Lumen support

Seems that there is a problem with this package in Lumen. It relies on trans() function, that is only present in Laravel, but not in Lumen (although it has a dependency on illuminate/translate)

Support custom validation message for greaterxxxx, ...

Currently, I can't find any way that can add validation messsage for, e.g: greaterthanorequal in the locale that is not available.

Guide me someway to do that, please.

The result currently in chinese is like:
Image 的尺寸要宽greater than or equal to 600 pixels和高greater than or equal to 600 pixels

I find no way to change
'greaterthanorequal' => 'greater than or equal to :size pixels',
this part because it has a namespace.

Illegal string offset 'image_size' error after installation

Hey,

Firstly, thanks for the plugin! it's much appreciated!

I have an issue, I hope you can help me:

My Laravel version is 4.1.24
arda@arda-pc ~/web/mywork $ php artisan --version Laravel Framework version 4.1.24

This is my PHP Version (using Linux Mint 16 x64):
PHP 5.5.3-1ubuntu2.2 (cli) (built: Feb 28 2014 20:06:05) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies with Zend OPcache v7.0.3-dev, Copyright (c) 1999-2013, by Zend Technologies

After installation, when I add the service provider in app/config/app.php, I get an error like this:

Illegal string offset 'image_size'
File: /home/arda/web/mywork/vendor/cviebrock/image-validator/src/Cviebrock/ImageValidator/ImageValidatorServiceProvider.php

Error is showing this method on Whoops:

protected function extendValidator($rule) { $method = studly_case($rule); $translation = $this->app['translator']->get('image-validator::validation'); $this->app['validator']->extend($rule, 'Cviebrock\ImageValidator\ImageValidator@validate' . $method, $translation[$rule]); $this->app['validator']->replacer($rule, 'Cviebrock\ImageValidator\ImageValidator@replace' . $method ); }

How can I fix this?

Edit: I've found a temporary fix, by adding a tr/validation.php (my language setting is tr) into your src folder, I've tried adding them to my app/lang/tr/validation.php but that didn't work.

Is there a proper workaround?

Thanks,

Do you really need PHP>=5.4

As long as Laravel 4.1 needs php>=5.3.3, if you really do not need 5.4 you are limiting your package to laravel 4.2.

Laravel 5.4

I can't require the image validator into Laravel 5.4.

I get the following error:

local.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: Type error: Argument 1 passed to Cviebrock\ImageValidator\ImageValidator::__construct() must be an instance of Symfony\Component\Translation\TranslatorInterface, instance of Illuminate\Translation\Translator given, called in /vendor/cviebrock/image-validator/src/ImageValidatorServiceProvider.php on line 35 in /vendor/cviebrock/image-validator/src/ImageValidator.php:15

Laravel 5 throwing an error

I'm guessing this package hasn't been setup for Laravel 5, but thought I'd let you know that if I try to use it I get an error:

Exception in Store.php line 236:
Serialization of 'Symfony\Component\HttpFoundation\File\UploadedFile' is not allowed

If I don't use any image-validator rules, say just use 'photo' => 'required|image', then the validation works and I can move on to the next step.

Anyone have any luck getting this working in L5?

Support laravel 5.1

laravel 5.1 not supports. Please check

BadMethodCallException in Validator.php line 2676:
Method [validateImageSize] does not exist.

Validate image weight

It would be nice to validate the image weight too, like 1 Mb, things like that, didn't know where to submit a suggestion

Support for irrational numbers

I was trying an aspect ratio of 3,2, with an image of 1024x682 and another of 1024x683 but it didn't pass. I'm guessing it's because the correct height would be 862.66666666..... Can we have support for this? Maybe like flooring or ceiling the result could work. Thanks in advance!

"PHP function nesting level of '5000' has been reached", if there's another extended validation

Hey again,

I have found a new error on my end, I hope you can help me:

When I add another extended validation from another place, I get an error like this if image_size rule is run from validation:

Symfony \ Component \ Debug \ Exception \ FatalErrorException
Aborting! The New Relic imposed maximum PHP function nesting level of '5000' has been reached. This limit is to prevent the PHP execution from catastrophically running out of C-stack frames. If you think this limit is too small, adjust the value of the setting newrelic.special.max_nesting_level in the newrelic.ini file, and restart php. Please file a ticket at https://support.newrelic.com if you need further assistance.

This is my extension of Laravel Validation Class: http://laravel.io/bin/MN8l

To enable this, I've added this line in my index.php before $app->run();:

require_once __DIR__.'/app/lib/Validation.php';

The error occurs on the method __call() on my app/lib/validation.php as Whoops says.

What could be the issue, is there any way to resolve this?

Thanks in advance,

validation of image URL

Is it possible to use this, or change it, to allow the validation of linked images? The stock laravel validations only work if you upload an image to the server, but obviously don't work, if you add an image via an URL.

Validation Message for Aspect Ratio Validation

The validation message for the aspect ratio only lists the first value in the error message.
ie: an aspect ratio of 8,5 results in a validation message that reads: The image-{image name} aspect ratio must be 8.

GD-ext required?

Thanks for this library, pretty sweet.

I poked around a bit and couldn't find why the GD extension was required. Is there a reason?

Can this be safely removed or is there something I'm missing?

Thanks in advance!

Argument 4 passed to Cviebrock\ImageValidator\ImageValidator::__construct() must be of the type array

Hello,

I've been getting this error since a recent update.

Type error: Argument 4 passed to Cviebrock\ImageValidator\ImageValidator::__construct() must be of the type array, string given, called in /home/vagrant/monitoring-assistance/vendor/cviebrock/image-validator/src/ImageValidatorServiceProvider.php on line 34

This error is fixed by not type hinting for an array as the forth argument. This issue from what I could debug is that the translations aren't loaded, and thus the key is sent to the constructor.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.