<commit_before><?php
namespace FormKit\Widget;
use FormKit\Element;
use FormKit\Element\Div;

/**
 *
 * $input = new ImageFileInput('image');
 * $input->image->align = 'right';
 * $input->image->src = '.....';
 * $input->imageCover->setAttributeValues(....);
 * $input->render();
 *
 */
class ThumbImageFileInput extends TextInput
{
    public $type = 'file';
    public $image;
    public $imageCover;
    public $inputWrapper;
    public $fileInput;
    public $prefix = '';

    protected $_ignoredAttributes = array( 'value' => true );

    /**
     * To enable resize checkbox
     *
     * $widget = new FormKit\ThumbImageFileInput('image',array( 'resize' => true ))
     *
     */
    public $resize = false;

    /**
     * Option to disable/enable exif.
     */
    public $exif = false;

    /**
     * HTML structure
     *
     * <div class="formkit-widget formkit-widget-thumbimagefile formkit-image-wrapper">
     *    <div class="formkit-image-cover">
     *      <img src="...."/>
     *    </div>
     *    <input type="file"...>
     * </div>
     *
     */

    public function init() 
    {
        parent::init();
        $this->fileInput = new FileInput( $this->name, $this->attributes );

        $this->imageCover = new Div(array('class' => 'formkit-image-cover'));
        $this->imageCover->setAttributeValue('data-width', $this->dataWidth);
        $this->imageCover->setAttributeValue('data-height', $this->dataHeight);

        $this->inputWrapper = new Div;
        $this->inputWrapper->addClass('formkit-widget-thumbimagefile')
            ->addClass('formkit-image-wrapper');

        // if with value, then generate img
        if ( $this->value ) {
            $this->image = new Element('img',array(
                'src' => $this->prefix . $this->value,
            ));
            $this->imageCover->append($this->image);
        }

        // TODO: c9, you can make exif button as a config, by EJ
        if($this->exif) {
            $this->fileInput->setAttributeValue('data-exif', 'true');
        }

        $this->inputWrapper->append($this->imageCover);
        $this->inputWrapper->append($this->fileInput);
    }

    public function render($attributes = array() ) 
    {
        return $this->inputWrapper->render();
        // parent::render($attributes);
    }
}<commit_msg>register data-resize<commit_after><?php
namespace FormKit\Widget;
use FormKit\Element;
use FormKit\Element\Div;

/**
 *
 * $input = new ImageFileInput('image');
 * $input->image->align = 'right';
 * $input->image->src = '.....';
 * $input->imageCover->setAttributeValues(....);
 * $input->render();
 *
 */
class ThumbImageFileInput extends TextInput
{
    public $type = 'file';
    public $image;
    public $imageCover;
    public $inputWrapper;
    public $fileInput;
    public $prefix = '';

    protected $_ignoredAttributes = array( 'value' => true );

    /**
     * To enable resize checkbox
     *
     * $widget = new FormKit\ThumbImageFileInput('image',array( 'resize' => true ))
     *
     */
    public $resize = false;

    /**
     * Option to disable/enable exif.
     */
    public $exif = false;

    /**
     * HTML structure
     *
     * <div class="formkit-widget formkit-widget-thumbimagefile formkit-image-wrapper">
     *    <div class="formkit-image-cover">
     *      <img src="...."/>
     *    </div>
     *    <input type="file"...>
     * </div>
     *
     */

    public function init() 
    {
        parent::init();
        $this->fileInput = new FileInput( $this->name, $this->attributes );

        $this->imageCover = new Div(array('class' => 'formkit-image-cover'));
        $this->imageCover->setAttributeValue('data-width', $this->dataWidth);
        $this->imageCover->setAttributeValue('data-height', $this->dataHeight);

        $this->inputWrapper = new Div;
        $this->inputWrapper->addClass('formkit-widget-thumbimagefile')
            ->addClass('formkit-image-wrapper');

        // if with value, then generate img
        if ( $this->value ) {
            $this->image = new Element('img',array(
                'src' => $this->prefix . $this->value,
            ));
            $this->imageCover->append($this->image);
        }

        if ($this->exif) {
            $this->fileInput->setAttributeValue('data-exif', 'true');
        }
        if ($this->resize) {
            $this->fileInput->setAttributeValue('data-resize','true');
        }

        $this->inputWrapper->append($this->imageCover);
        $this->inputWrapper->append($this->fileInput);
    }

    public function render($attributes = array() ) 
    {
        return $this->inputWrapper->render();
        // parent::render($attributes);
    }
}
{'fraction_non_alphanumeric': 0.1759948925303256, 'fraction_numerical': 0.00021281123643328368, 'mean_word_length': 2.3098591549295775, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 104, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5096710', 'n_tokens_mistral': 1418, 'n_tokens_neox': 1379, 'n_words': 255}