public static function image_reprocess() { if (isset($_REQUEST['fid'])) { $image_size = new image_size([], $_REQUEST['fid']); $image_size->reprocess(); } }
/** * @return \html\node */ public function get_view() { $images = image_size::get_all([]); if ($images) { $html = node::create('div', [], node::create('table.module', [], node::create('thead', [], node::create('th', [], 'Field ID') . node::create('th', [], 'Title') . node::create('th', [], '')) . $images->iterate_return(function (image_size $image_size) { return node::create('tr', [], node::create('td', [], $image_size->fid) . node::create('td', [], $image_size->title) . node::create('td a.button', ['href' => '?module=cms&act=image_reprocess&fid=' . $image_size->isid], 'Reprocess')); }))); return $html; } return ''; }
public function get_html_wrapper() { $html = ''; $html .= $this->pre_text; if (!$this->hidden && isset($this->label) && !empty($this->label)) { $html .= node::create('label.control-label.col-md-' . $this->parent_form->bootstrap[0], ['for' => $this->field_name, 'id' => $this->field_name . '_wrapper'], $this->label); } $parent = $this->parent_form; if ($parent instanceof table) { $primary = $parent->get_primary_key(); } else { $primary = $parent->source_table->get_primary_key(); } $image_size = new image_size(); $options = ['where_equals' => ['fid' => $this->fid, 'default_edit' => true]]; $image_size->do_retrieve([], $options); $attributes = ['style' => ['width' => $image_size->max_width . 'px', 'height' => $image_size->max_height . 'px']]; $html .= node::create('div.fileinput.fileinput-new.input_group.col-md-' . $this->parent_form->bootstrap[1], ['data-provides' => 'fileinput'], [node::create('div.fileinput-new.thumbnail', $attributes, $this->get_default_image($primary, $options)), node::create('div.fileinput-preview.fileinput-exists.thumbnail', $attributes, ''), node::create('div', [], [node::create('span.btn.btn-default.btn-file', [], [node::create('span.fileinput-new', [], 'Select File'), node::create('span.fileinput-exists', [], 'Change'), $this->get_html()]), node::create('a.btn.btn-default.fileinput-exists', ['data-dismiss' => 'fileinput'], 'Remove')])]); $html .= $this->post_text; return $html; }
protected function do_process_image($source, image_size $size) { $ext = pathinfo($source, PATHINFO_EXTENSION); $resize = new image_resizer($source); $resize->resizeImage($size->max_width, $size->max_height, $size->icid == 1 ? true : false); $resize->saveImage(str_replace('.' . $ext, '', $source) . '_' . $size->reference . '.' . $size->get_format()); }