/** * Return language flag image url * * @param int $id * @param mixed $attrs Html attributes of the flag image */ function flag($id = null, $attrs = array()) { if (empty($id)) { $id = $this->langID(); } //if $objLang = new Language(); $lang = $objLang->read('flag', $id); return $this->Html->image('/img/flags/' . $lang['Language']['flag'], $attrs); }
public function image($path, $options = array()) { if (empty($path)) { $path = 'no_image.png'; } else { if (isset($options['section'])) { switch ($options['section']) { case 'UserProfile': $path = Configure::read('ImagePath.UserProfile') . $path; break; case 'AdvisorProfile': $path = Configure::read('ImagePath.AdvisorProfile') . $path; break; case 'temp': $path = Configure::read('ImagePath.temp') . $path; break; case 'Job': $path = Configure::read('ImagePath.Job') . $path; break; case 'BusinessField': $path = Configure::read('ImagePath.BusinessField') . $path; break; } } } return parent::image($path, $options); }
/** * * @param string $path * @param array $options * @return @return string completed img tag */ public function image($path, $options = array()) { if (preg_match('!^http://a[0-9]+\\.twimg\\.com/!', $path) && env('HTTPS')) { $path = preg_replace('!^http://a[0-9]+\\.twimg\\.com/!', 'https://s3.amazonaws.com/twitter_production/', $path); } return $this->Html->image($path, $options); }
/** * Adds support for lazy loading images * Set "lazy" => true in $options array to activate * @param string $path * @param array $options * @return string */ public function image($path, $options = array()) { $image = parent::image($path, $options); // Special options for lazy loading if (isset($options['lazy']) && $options['lazy'] === true) { // Unset useless lazy options unset($options['lazy']); // Add "lazy" to class attribute if (isset($options['class'])) { $classes = explode(' ', $options['class']); $classes[] = 'lazy'; $options['class'] = implode(' ', $classes); } else { $options['class'] = 'lazy'; } // Set fake image if no image set if (!$path) { $path = '/img/'; } // Store original path in data attribute $options['data-original'] = $path; // Set path to transparent gif $path = 'transparent.gif'; // Create <noscript> for SEO purposes $noscript = sprintf("<noscript>%s</noscript>", $image); // Concatenate both $image = parent::image($path, $options) . $noscript; } return $image; }
/** * Creates a formatted IMG element for preview images. * * @see HtmlHelper::image() * @param string $path Image Path * @param array $options Options list * @return string Completed img tag */ public function thumbnail($path, $options = array()) { $class = $this->Theme->getCssClass('thumbnailClass'); if (empty($options['class'])) { $options['class'] = $class; } return parent::image($path, $options); }
/** * Creates a formatted IMG element for preview images. * * @see HtmlHelper::image() * @param string $path Image Path * @param array $options Options list * @return string Completed img tag */ public function thumbnail($path, $options = array()) { $class = $this->_View->viewVars['themeSettings']['css']['thumbnailClass']; if (empty($options['class'])) { $options['class'] = $class; } return parent::image($path, $options); }
public function image($path, $options = array()) { if ($this->settings['altEqualTitle']) { if (isset($options['alt']) && !isset($options['title'])) { $options['title'] = $options['alt']; } elseif (isset($options['title']) && !isset($options['alt'])) { $options['alt'] = $options['title']; } } return parent::image($path, $options); }
/** * Creates a formatted IMG element. * * This method will set an empty alt attribute if one is not supplied. * * ### Usage: * * Create a regular image: * * `echo $this->Html->image('cake_icon.png', array('alt' => 'CakePHP'));` * * Create an image link: * * `echo $this->Html->image('cake_icon.png', array('alt' => 'CakePHP', 'url' => 'http://cakephp.org'));` * * ### Options: * * - `url` If provided an image link will be generated and the link will point at * `$options['url']`. * - `fullBase` If true the src attribute will get a full address for the image file. * - `plugin` False value will prevent parsing path as a plugin * - `data-src` For holder.js options. If `$path` is not empty, then unset `$options['data-src']`. * * @param string $path Path to the image file, relative to the app/webroot/img/ directory. * @param array $options Array of HTML attributes. See above for special options. * @return string completed img tag * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html#HtmlHelper::image */ public function image($path, $options = array()) { if (empty($path)) { $path = '/'; } else { if (isset($options['data-src'])) { unset($options['data-src']); } } return parent::image($path, $options); }
/** * image * With auto sizing/formatting built in. * @param string $path * @param array $ops * @return string */ public function image($path, $opts = array()) { if (isset($opts['w']) || isset($opts['h'])) { $path = $this->Image->make($path, $opts); foreach ($this->Image->phpThumb as $key => $val) { unset($opts[$key]); } } $base = substr(Router::url('/'), 0, -1); if (!empty($base) && substr($path, 0, strlen($base)) == $base) { $path = substr($path, strlen($base)); } return parent::image($path, $opts); }
/** * (non-PHPdoc) * @see GalleryHelper::get_markup() */ public function get_markup() { $toret = ''; if (count($this->images) > 0) { $subs = new SubstitutionTemplate(); $subs->set_tpl($this->tpl)->set_markup('prev', HtmlHelper::anchor('javascript:;', '<', array('class' => 'prev control')))->set_markup('next', HtmlHelper::anchor('javascript:;', '>', array('class' => 'next control'))); ThemeHelpers::load_js('minigallery-thumbs-link-to-big'); ThemeHelpers::load_css('jquery-fancybox'); foreach ($this->images as $index => $image) { $image_big = wp_get_attachment_image_src($this->get_image_id($index), $this->media_dimension_big); $image_small = wp_get_attachment_image_src($this->get_image_id($index), $this->media_dimension); $toret .= HtmlHelper::anchor($image_big[0], HtmlHelper::image($this->get_image_src($index), array('alt' => $this->get_image_alt($index), 'title' => $this->get_image_description($index), 'data-caption' => $this->get_image_caption($index))), array('class' => 'fancybox', 'rel' => 'group', 'title' => $this->get_image_caption($index))); } $toret = $subs->set_markup('list', $toret)->replace_markup(); } return $toret; }
/** * Creates a formatted IMG element. * Allow calling directly with media data * * @param string $path Path to the image file, relative to the app/webroot/img/ directory. * @param array $options Array of HTML attributes. * @return string */ public function image($path, $options = array()) { if (is_array($path)) { $data = $path; $path = $this->imageUrl($data, $options); if (is_string($options)) { $args = func_get_args(); if (!empty($args[2])) { $options = $args[2]; } else { $options = array(); } } else { unset($options['size']); } $options = $this->imageAttributes($data, $options); } return parent::image($path, $options); }
/** * Callback for 'post_thumbnail_html' hook. * Changes the html markup if the post thumbnail is not set * @param string $html * @param unknown_type $post_id * @param unknown_type $post_thumbnail_id * @param unknown_type $size * @param unknown_type $attr */ public function post_thumbnail_html_callback($html, $post_id, $post_thumbnail_id, $size, $attr) { if ($post_thumbnail_id == -1) { $sizes = self::get_all_image_sizes(); if (empty($size) || !in_array($size, array_keys($sizes))) { $size = 'medium'; } return HtmlHelper::image(admin_url('admin-ajax.php') . '?' . build_query(array('action' => 'placeholder', 'w' => $sizes[$size]['width'], 'h' => $sizes[$size]['height']), array('alt' => __('Placeholder post thumbnail'), 'width' => $sizes[$size]['width'], 'height' => $sizes[$size]['height']))); } return $html; }
function iconlink($icon, $title, $url = null, $htmlAttributes = array(), $confirmMessage = false) { $img = parent::image("/authake/img/icons/{$icon}.png", array('title' => $title)); return parent::link($img, $url, am($htmlAttributes, array('escape' => false)), $confirmMessage, false); }
/** * Retrieves the markup for this minigallery * @return the markup for the minigallery */ public function get_markup() { $toret = ''; if (count($this->images) > 0) { $this->load_assets(); $thumb_list = ''; foreach ($this->images as $k => $image) { if ($k % $this->thumb_list_config['number'] == 0 && $k > 0) { $thumb_list .= $this->thumb_list_config['separator']['close'] . $this->thumb_list_config['separator']['open']; } // $src = $this->get_image_src($k); $big_img_link = wp_get_attachment_image_src($this->get_image_id($k), $this->sizes['big']); // vd($big_img_link); $small_img_link = wp_get_attachment_image_src($this->get_image_id($k), $this->sizes['small']); $thumb_list .= HtmlHelper::anchor($big_img_link[0], HtmlHelper::image($small_img_link[0], array('class' => 'image')), array('class' => 'thumb-link', 'data-caption' => $this->get_image_caption($k))); } if (!$this->unid) { $this->calculate_unique(); } $this->static_markup['minigallery-id'] = $this->unid; $this->static_markup['thumb-list'] = $this->thumb_list_config['separator']['open'] . $thumb_list . $this->thumb_list_config['separator']['close']; $toret = str_replace(array_map(create_function('$k', 'return "%".$k."%";'), array_keys($this->static_markup)), array_values($this->static_markup), $this->tpl); } return $toret; }
/** * This function overrides the HtmlHelper image() function. * It provides: * * - an automatic image resize if a 'maxWidth' and/or 'maxHeight' value are given in the options * the function tries to determine the physical height and width of the image, in order to prevent enlarging * an image if the given maxWidth and/or maxHeight are larger the image dimensions. * * - the replacement of the image by a alternative image set as 'not_found' in the options * if the $path does not point to an existing image * * @param $path * @param $options */ function image($path, $options = array()) { /* * Parse $path to determine if it is a path in a plugin or not */ $url = Router::parse($path); $plugin = empty($url['plugin']) ? null : $url['plugin']; /* * If the options contains an image path to replace a missing image * -> checks if the requested image exists */ $file_path = ''; $pic_path = ''; if (isset($options) && is_array($options)) { if (isset($plugin)) { $plugin_path = App::pluginPath($plugin); $subpath = str_replace('/' . $plugin, '', $path); if (file_exists($plugin_path . 'webroot/' . $subpath) && is_file($plugin_path . 'webroot/' . $subpath)) { $file_path = $plugin_path . 'webroot/' . $subpath; } elseif (isset($options['not_found'])) { $path = $options['not_found']; } } else { if (file_exists(WWW_ROOT . 'img/' . $path) && is_file(WWW_ROOT . 'img/' . $path)) { $file_path = WWW_ROOT . 'img/' . $path; } elseif (file_exists(WWW_ROOT . $path) && is_file(WWW_ROOT . $path)) { $file_path = WWW_ROOT . $path; } elseif (isset($options['not_found'])) { $path = $options['not_found']; } } } if (strlen($file_path) > 0) { if (file_exists($file_path)) { $imgInfos = getimagesize($file_path); } $width = $imgInfos[0]; $height = $imgInfos[1]; if (isset($options['maxWidth']) && isset($options['maxHeight'])) { if ($options['maxWidth'] < $width) { $options['width'] = $options['maxWidth']; $newHeight = $options['width'] * $height / $width; if ($options['maxHeight'] < $newHeight) { $options['height'] = $options['maxHeight']; unset($options['width']); } } else { if ($options['maxHeight'] < $height) { $options['height'] = $options['maxHeight']; } } } elseif (isset($options['maxWidth'])) { if ($options['maxWidth'] < $width) { $options['width'] = $options['maxWidth']; } } elseif (isset($options['maxHeight'])) { if ($options['maxHeight'] < $height) { $options['height'] = $options['maxHeight']; } } if (isset($options['maxHeight'])) { unset($options['maxHeight']); } if (isset($options['maxWidth'])) { unset($options['maxWidth']); } } return parent::image($path, $options); }
/** * (non-PHPdoc) * @see GalleryHelper::get_markup() */ public function get_markup() { $markup_images = ''; if (count($this->images) > 0) { $images_per_line = $this->images_per_row; foreach ($this->images as $k => $image) { $classes = array($this->single_image_container_class, 'image_' . $k); if ($images_per_line == 0) { $images_per_line = $this->images_per_row; } if ($images_per_line == $this->images_per_row) { $classes[] = 'alpha'; } if ($images_per_line == 1) { $classes[] = 'omega'; } $images_per_line--; $big_img_src = wp_get_attachment_image_src($this->get_image_id($k), 'full'); $big_img_src = $big_img_src[0]; $markup_images .= '<div class="' . implode(' ', $classes) . '">' . HtmlHelper::anchor($big_img_src, HtmlHelper::image($this->get_image_src($k), array('alt' => $this->get_image_alt($k))), array('rel' => 'group', 'class' => 'fancy', 'title' => $this->get_image_title($k), 'data-description' => $this->get_image_description($k), 'data-caption' => $this->get_image_caption($k))) . '</div>'; } } if (!$this->unid) { $this->calculate_unique(); } $this->subs->set_markup('gallery-id', $this->unid); $this->subs->set_markup('images', $markup_images); ThemeHelpers::load_js('jquery-fancybox'); ThemeHelpers::load_css('jquery-fancybox'); return $this->subs->replace_markup(); }
/** * Use local settings to select an icon. */ function icon($img, $imgOptions = array()) { $base_folder = Configure::read('folders.icon_base'); $base_url = Configure::read('urls.zuluru_img'); $icon_pack = Configure::read('icon_pack'); if ($icon_pack == 'default') { $icon_pack = ''; } else { $icon_pack = "/{$icon_pack}"; } if (file_exists("{$base_folder}{$icon_pack}/{$img}")) { return parent::image("{$base_url}{$icon_pack}/{$img}", $imgOptions); } if (file_exists("{$base_folder}/{$img}")) { return parent::image("{$base_url}/{$img}", $imgOptions); } return parent::image($img, $imgOptions); }
/** * Picture * * Extends from HtmlHelper:image() * * @param string $path Path to the image file, relative to the app/webroot/img/ directory. * @param array $options Array of HTML attributes. See above for special options. * @return string End tag header * * Extra options * - ga_shape : string Shape of the images GA_ROUNDED|GA_CIRCLE|GA_POLAROID */ public function image($path, $options = []) { $shapes = [GA_ROUNDED, GA_CIRCLE, GA_POLAROID]; if (!empty($options['ga_shape'])) { if (in_array($options['ga_shape'], $shapes)) { $options = $this->addClass($options, $options['ga_shape']); } unset($options['ga_shape']); } return parent::image($path, $options); }
/** * Get the image for the tab. * * build the image for this tab: take it from the media * library if the parameter is a number, use such parameter * as src attribute for img tag if it's not a number. * @param int|string $parm id of the image or string of the src parameter */ private function get_image($parm) { if (empty($parm)) { return ''; } return is_numeric($parms['icon']) ? wp_get_attachment_image($parms['icon']) : HtmlHelper::image($parms['icon']); }
/** * Picture responsive * * Extends from HtmlHelper:image() * * @param string $path Path to the image file, relative to the app/webroot/img/ directory. * @param array $options Array of HTML attributes. See above for special options. * @return string End tag header */ public function image($path, $options = array()) { if (isset($options['class'])) { $options['class'] = 'img-responsive ' . $options['class']; } else { $options['class'] = 'img-responsive'; } return parent::image($path, $options); }
/** * Renders a single element of the slideshow * @param int $k the index of the element in $this->images array * @return string html markup for the given element */ private function render_element($k) { $toret = HtmlHelper::image($this->get_image_src($k), array('alt' => $this->get_image_alt($k), 'data-desc' => $this->get_image_description($k), 'data-caption' => $this->get_image_caption($k), 'id' => $this->get_image_id($k), 'width' => $this->get_image_width($k), 'height' => $this->get_image_height($k))); return $toret; }
function upload_pic() { $this->autoRender = false; $r = $this->Session->read('User.id'); if (!empty($_FILES)) { $tempFile = $_FILES['Filedata']['tmp_name']; //$ext = substr($_FILES['Filedata']['name'], strrpos($_FILES['Filedata']['name'], '.') + 1); $image_info = getimagesize($_FILES['Filedata']['tmp_name']); //print_r($image_info); $file_new_name = time(); if ($image_info['mime'] == 'image/jpeg') { $original = imagecreatefromjpeg($_FILES['Filedata']['tmp_name']); } elseif ($image_info['mime'] == 'image/png') { $original = imagecreatefrompng($_FILES['Filedata']['tmp_name']); } elseif ($image_info['mime'] == 'image/gif') { $original = imagecreatefromgif($_FILES['Filedata']['tmp_name']); } else { exit; } $new_images[0] = 'medium'; $new_images[1] = 'small'; foreach ($new_images as $image) { if ($image == 'medium') { $small = 99; $large = 111; } else { $small = 45; $large = 47; } $ratioOrig = $image_info[0] / $image_info[1]; if ($ratioOrig < 1) { $width = $small; $height = $large; } elseif ($ratioOrig == 1) { $width = $large; $height = $large; } else { $width = $large; $height = $small; } $new_image = imagecreatetruecolor($width, $height); if ($image_info['mime'] == 'image/png') { $kek = imagecolorallocate($new_image, 255, 255, 255); imagefill($new_image, 0, 0, $kek); } imagecopyresampled($new_image, $original, 0, 0, 0, 0, $width, $height, $image_info[0], $image_info[1]); $createJpg = imagejpeg($new_image, $_SERVER['DOCUMENT_ROOT'] . '/payroll/webroot/files/pic/' . $image . '/' . $file_new_name . '.jpg', 80); ImageDestroy($new_image); } $original_upload = imagecreatetruecolor($image_info[0], $image_info[1]); $kek = imagecolorallocate($original_upload, 255, 255, 255); imagefill($original_upload, 0, 0, $kek); imagecopyresampled($original_upload, $original, 0, 0, 0, 0, $image_info[1], $image_info[1], $image_info[0], $image_info[1]); $createJpg = imagejpeg($original_upload, $_SERVER['DOCUMENT_ROOT'] . '/payroll/webroot/files/pic/' . $file_new_name . '.jpg', 80); //$this->User->id=$r; //$this->data['User']['attachmentName']=$file_new_name.'.jpg'; //$this->User->save($this->data); //$path='/files/pic/'.$file_new_name.'.jpg'; //App::import('Helper', 'Html'); $path = '/payroll/files/pic/' . $file_new_name . '.jpg'; $html = new HtmlHelper(new View(null)); echo $html->image($path, array('alt' => 'Profile pic')); // $fileTypes = str_replace('*.','',$_REQUEST['fileext']); // $fileTypes = str_replace(';','|',$fileTypes); // $typesArray = split('\|',$fileTypes); // $fileParts = pathinfo($_FILES['Filedata']['name']); // if (in_array($fileParts['extension'],$typesArray)) { // Uncomment the following line if you want to make the directory if it doesn't exist // mkdir(str_replace('//','/',$targetPath), 0755, true); //move_uploaded_file($tempFile,$targetFile); //echo str_replace($_SERVER['DOCUMENT_ROOT'],'',$targetFile); // } else { // echo 'Invalid file type.'; // } } }