本文整理汇总了PHP中Image::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Image::get方法的具体用法?PHP Image::get怎么用?PHP Image::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Image
的用法示例。
在下文中一共展示了Image::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ImageTag
public function ImageTag()
{
if (is_numeric($this->Image())) {
return Image::get()->byID($this->Image())->SetSize($this->imageWidth, $this->imageHeight)->getTag();
}
return $this->image;
}
示例2: runBeforeTemplateParsing
protected function runBeforeTemplateParsing($objTemplate, $objItem)
{
$this->imgSize = deserialize($this->imgSize, true);
if ($objTemplate->isAuthor && !$objItem->raw['published']) {
$objTemplate->unpublished = true;
}
// media
$strMedia = '';
if ($objItem->raw['mediaType'] == 'video') {
$objItem->addYouTube = true;
$objItem->youtube = preg_replace('@.*watch\\?v=([^&]+).*@i', '$1', $objItem->pinBoardYouTube);
$objYouTube = YouTubeVideo::getInstance()->setData($objItem->row());
$objYouTube->autoplay = true;
$strMedia = $objYouTube->generate();
} elseif ($objItem->pinBoardImage) {
$strMedia = $objItem->pinBoardImage;
}
if ($strMedia && $objItem->raw['mediaType'] == 'image') {
$objTemplate->media = \Image::get($strMedia, $this->imgSize[0], $this->imgSize[1], $this->imgSize[2]);
$arrSize = getimagesize(urldecode(TL_ROOT . '/' . $objTemplate->media));
if (count($arrSize) > 1) {
$objTemplate->imgSizeParsed = 'width="' . $arrSize[0] . '" height="' . $arrSize[1] . '"';
}
} else {
$objTemplate->media = $strMedia;
}
}
示例3: cachedImages
/**
* cache the images to static::$images
*
* @param $template
*
* @throws \Exception
*/
public function cachedImages($template)
{
if (TL_MODE === 'FE') {
/** @var \PageModel $objPage */
global $objPage;
$layout = $objPage->getRelated('layout');
if ($layout->activateImageSecSet && $template->singelSRC || $template->multiSRC) {
$template->size = deserialize($template->size);
if ($template->size[0] || $template->size[1]) {
if ($image = $template->singleSRC) {
$images = array($image);
}
if ($images = $template->multiSRC) {
if (!is_array($images)) {
$images = deserialize($images);
}
}
if (is_array($images)) {
foreach ($images as $image) {
$file = \FilesModel::findByUuid($image);
$path = \Image::get($file->path, $template->size[0], $template->size[1], $template->size[2]);
$buffer = array('path' => $file->path);
if (!isset(static::$images[$path])) {
static::$images[$path] = $buffer;
}
}
}
}
}
}
}
示例4: generate
/**
* @return string
*/
public function generate()
{
if (TL_MODE === 'BE') {
$template = new \BackendTemplate('be_wildcard');
$template->wildcard = '### ANTRAGO Event-Details ###';
$template->title = 'Event Details';
//"Kategorien: " . implode(', ',deserialize($this->arrData['ac_categories']));
return $template->parse();
}
// hole event details;
$url = $_SERVER["REQUEST_URI"];
$id = explode("veranstaltung=", $url)[1];
$this->configuration = AntragoConnector::getAntragoConfiguration($this->arrData['ac_event_details_config']);
$db = \Database::getInstance();
$this->product = $db->prepare("SELECT * FROM tl_antrago_products WHERE productId=?")->execute($id)->fetchAssoc();
$this->formConfig = array('showRegisterForm' => $this->arrData['ac_event_details_show_register'], 'showApplicationForm' => $this->arrData['ac_event_details_show_applicationform']);
// contact
$this->contact = $db->prepare("SELECT * FROM tl_antrago_contacts WHERE id =?")->execute($this->product['productContact'])->fetchAssoc();
$oContactImage = \FilesModel::findByPk($this->contact['image']);
// Add cover image
if ($oContactImage !== null) {
$sImage = \Image::get($oContactImage->path, '80', '100', 'center_center');
}
$this->contact['image'] = $sImage;
return parent::generate();
}
示例5: localupdate
public function localupdate()
{
if ($this->canEdit() && ($imageDataString = $this->request->requestVar('imageData')) && ($imageID = $this->request->requestVar('imageID')) && ($image = Image::get()->byID(Convert::raw2sql($imageID)))) {
//$imageDataString = file_get_contents($newFile);
$imageData = base64_decode(preg_replace('#^data:image/\\w+;base64,#i', '', $imageDataString));
$path = $image->getFullPath();
// if we have a new file + old path, overwrite old image wiith new image.
if ($imageData && $path) {
// Do we need to validate it the filetype is still the same as the original?
//$f = finfo_open();
//$mime_type = finfo_buffer($f, $imageData, FILEINFO_MIME_TYPE);
//finfo_close($f);
file_put_contents($path, $imageData);
$image->forceChange();
$image->deleteFormattedImages();
$image->write();
// return new thumbnail
$formattedImage = $image->getFormattedImage('SetWidth', Config::inst()->get('Image', 'asset_preview_width'));
$thumbnail = $formattedImage ? $formattedImage->URL : '';
if ($this->request->isAjax()) {
$this->request->addHeader('Content-type', 'application/json');
return json_encode(['thumbnail' => $thumbnail]);
}
return $thumbnail;
}
}
}
示例6: AutofixUrl
function &create(&$root, &$pipeline)
{
$name = $root->get_attribute('name');
$value = $root->get_attribute('value');
$url_autofix = new AutofixUrl();
$src = $url_autofix->apply(trim($root->get_attribute("src")));
$src_img = Image::get($pipeline->guess_url($src), $pipeline);
if (is_null($src_img)) {
error_log(sprintf("Cannot open image at '%s'", $src));
if ($root->has_attribute('width')) {
$width = px2pt($root->get_attribute('width'));
} else {
$width = px2pt(BROKEN_IMAGE_DEFAULT_SIZE_PX);
}
if ($root->has_attribute('height')) {
$height = px2pt($root->get_attribute('height'));
} else {
$height = px2pt(BROKEN_IMAGE_DEFAULT_SIZE_PX);
}
$alt = $root->get_attribute('alt');
$css_state =& $pipeline->getCurrentCSSState();
$box =& new ButtonBrokenImagebox($width, $height, $alt, $name, $value, $css_state->getProperty(CSS_HTML2PS_FORM_ACTION));
$box->readCSS($css_state);
return $box;
}
$css_state =& $pipeline->getCurrentCSSState();
$box =& new ButtonImageBox($src_img, $name, $value, $css_state->getProperty(CSS_HTML2PS_FORM_ACTION));
$box->readCSS($css_state);
$box->_setupSize();
return $box;
}
示例7: runBeforeTemplateParsing
protected function runBeforeTemplateParsing($objTemplate, $arrItem)
{
$objTemplate->ago = DateUtil::getTimeElapsed($arrItem['raw']['date']);
$objTemplate->commentCount = \CommentsModel::countPublishedBySourceAndParent('tl_news', $arrItem['fields']['id']);
$objTemplate->isAuthor = $arrItem['raw']['memberAuthor'] == \FrontendUser::getInstance()->id;
$this->imgSize = deserialize($this->imgSize, true);
if ($objTemplate->isAuthor && !$arrItem['raw']['published']) {
$objTemplate->unpublished = true;
}
// media
$strMedia = '';
if ($arrItem['raw']['mediaType'] == 'video') {
$arrItem['fields']['addYouTube'] = true;
$arrItem['fields']['youtube'] = preg_replace('@.*watch\\?v=([^&]+).*@i', '$1', $arrItem['fields']['pinBoardYouTube']);
$objYouTube = YouTubeVideo::getInstance()->setData($arrItem['fields']);
$strMedia = $objYouTube->getCachedYouTubePreviewImage();
} elseif ($arrItem['fields']['pinBoardImage']) {
$strMedia = $arrItem['fields']['pinBoardImage'];
}
if ($strMedia) {
$objTemplate->media = \Image::get($strMedia, $this->imgSize[0], $this->imgSize[1], $this->imgSize[2]);
$arrSize = getimagesize(urldecode(TL_ROOT . '/' . $objTemplate->media));
if (count($arrSize) > 1) {
$objTemplate->imgSizeParsed = 'width="' . $arrSize[0] . '" height="' . $arrSize[1] . '"';
}
}
}
示例8: processRecord
public function processRecord($record, $columnMap, &$results, $preview = false)
{
// Get Current Object
$objID = parent::processRecord($record, $columnMap, $results, $preview);
$object = DataObject::get_by_id($this->objectClass, $objID);
$this->extend("onBeforeProcess", $object, $record, $columnMap, $results, $preview);
// Loop through all fields and setup associations
foreach ($record as $key => $value) {
// Find any categories (denoted by a 'CategoryXX' column)
if (strpos($key, 'Category') !== false) {
$category = CatalogueCategory::get()->filter("Title", $value)->first();
if ($category) {
$object->Categories()->add($category);
}
}
// Find any Images (denoted by a 'ImageXX' column)
if (strpos($key, 'Image') !== false && $key != "Images") {
$image = Image::get()->filter("Name", $value)->first();
if ($image) {
$object->Images()->add($image);
}
}
// Find any related products (denoted by a 'RelatedXX' column)
if (strpos($key, 'Related') !== false && $key != "RelatedProducts") {
$product = Product::get()->filter("StockID", $value)->first();
if ($product) {
$object->RelatedProducts()->add($product);
}
}
}
$this->extend("onAfterProcess", $object, $record, $columnMap, $results, $preview);
$object->destroy();
unset($object);
return $objID;
}
开发者ID:alialamshahi,项目名称:silverstripe-catalogue-prowall,代码行数:35,代码来源:CatalogueProductCSVBulkLoader.php
示例9: cwsShortCodeRandomImageHandler
/**
* Displays a random image with colorbox effect from a given assets subfolder
* Uses template "csoft-shortcode/templates/Includes/RandomImage.ss" for output
*
* @param mixed $arguments (folder='subfolder_in_assets' align='left|right')
* @param $content = null
* @param $parser = null
* @return processed template RandomImage.ss
*/
public static function cwsShortCodeRandomImageHandler($arguments, $content = null, $parser = null)
{
// only proceed if subfolder was defined
if (!isset($arguments['folder'])) {
return;
}
// sanitize user inputs
$folder = Convert::raw2sql($arguments['folder']);
$align = isset($arguments['align']) ? strtolower(Convert::raw2xml($arguments['align'])) : '';
// fetch all images in random order from the user defined folder
$folder = Folder::get()->filter('Filename', "assets/{$folder}/")->First();
$randomImage = $folder ? Image::get()->filter('ParentID', $folder->ID)->sort('RAND()') : false;
// exit if user defined folder does not contain any image
if (!$randomImage) {
return;
}
// extract image caption from image filename
$caption = $randomImage->Title;
if (preg_match('#(\\d*-)?(.+)\\.(jpg|gif|png)#i', $caption, $matches)) {
$caption = ucfirst(str_replace('-', ' ', $matches[2]));
}
// prepare data for output
$data = array('RandomImage' => $randomImage->First(), 'Alignment' => $align, 'Caption' => $caption);
// load template and process data
$template = new SSViewer('RandomImage');
return $template->process(new ArrayData($data));
}
示例10: compile
/**
* Generate the module
*/
protected function compile()
{
$intList = $this->athletes_group;
$objMembers = $this->Database->prepare("SELECT * FROM tl_athlete WHERE published=1 AND pid=? ORDER BY sorting")->execute($intList);
//$objMembers = \MembersModel;
// Return if no Members were found
if (!$objMembers->numRows) {
return;
}
$strLink = '';
// Generate a jumpTo link
if ($this->jumpTo > 0) {
$objJump = \PageModel::findByPk($this->jumpTo);
if ($objJump !== null) {
$strLink = $this->generateFrontendUrl($objJump->row(), $GLOBALS['TL_CONFIG']['useAutoItem'] ? '/%s' : '/items/%s');
}
}
$arrMembers = array();
// Generate Members
while ($objMembers->next()) {
$strPhoto = '';
$objPhoto = \FilesModel::findByPk($objMembers->photo);
// Add photo image
if ($objPhoto !== null) {
$strPhoto = \Image::getHtml(\Image::get($objPhoto->path, '140', '187', 'center_center'));
}
$arrMembers[] = array('name' => $objMembers->name, 'family' => $objMembers->family, 'post' => $objMembers->post, 'joined' => $objMembers->joined, 'photo' => $strPhoto, 'link' => strlen($strLink) ? sprintf($strLink, $objMembers->alias) : '');
}
$this->Template->members = $arrMembers;
}
示例11: getArrayDados
/**
* @return array
* @todo Criar uma view no BD para retornar essas informações
*/
public function getArrayDados()
{
$informante = (new PessoaFisicaDAO())->getById($this->dto->getCdPfInformante());
$cd_condominio = '';
$condominio = '';
$condominio_foto = '';
$setor = '';
$setor_foto = '';
if ($this->dto->getCdSetor()) {
$setorDTO = (new SetorDAO())->getById($this->dto->getCdSetor());
$condominioDTO = (new PessoaJuridicaDAO())->getById($setorDTO->getCdCondominio());
$setor = $setorDTO->getNmSetor();
$setor_foto = Image::get($setorDTO);
$cd_condominio = $condominioDTO->getCdPessoaJuridica();
$condominio = $condominioDTO->getNmFantasia();
$condominio_foto = Image::get($condominioDTO);
}
$categoria = new CategoriaValorDAO();
$estagio = '';
if ($this->dto->getCdCatgEstagio()) {
$catg = $categoria->getBy2Ids($this->dto->getCdVlCatgEstagio(), $this->dto->getCdCatgEstagio());
$estagio = $catg->getDescVlCatg();
}
$tipo = '';
if ($this->dto->getCdCatgTipo()) {
$catg = $categoria->getBy2Ids($this->dto->getCdVlCatgTipo(), $this->dto->getCdCatgTipo());
$tipo = $catg->getDescVlCatg();
}
return array('cd_ocorrencia' => $this->dto->getCdOcorrencia(), 'cd_setor' => $this->dto->getCdSetor(), 'setor' => $setor, 'setor_foto' => $setor_foto, 'cd_condominio' => $cd_condominio, 'condominio' => $condominio, 'condominio_foto' => $condominio_foto, 'cd_pf_informante' => $this->dto->getCdPfInformante(), 'informante' => $informante->getNmPessoaFisica(), 'informante_foto' => Image::get($informante), 'desc_assunto' => $this->dto->getDescAssunto(), 'desc_ocorrencia' => $this->dto->getDescOcorrencia(), 'dt_ocorrencia' => (new DateTime($this->dto->getDtOcorrencia()))->format('d/m/Y'), 'dt_fim' => $this->dto->getDtFim() ? (new DateTime($this->dto->getDtFim()))->format('d/m/Y') : 'em aberto', 'desc_conclusao' => $this->dto->getDescConclusao(), 'cd_catg_estagio' => $this->dto->getCdCatgEstagio(), 'cd_vl_catg_estagio' => $this->dto->getCdVlCatgEstagio(), 'estagio' => $estagio, 'cd_catg_tipo' => $this->dto->getCdCatgTipo(), 'cd_vl_catg_tipo' => $this->dto->getCdVlCatgTipo(), 'tipo' => $tipo);
}
示例12: getArrayDados
public function getArrayDados()
{
$pessoaFisicaDao = new PessoaFisicaDAO();
$setorDTO = (new SetorDAO())->getById($this->dto->getCdSetor());
$setorDados = (new SetorModel())->setDTO($setorDTO)->getArrayDados();
$executor = '';
$executor_foto = '';
if ($this->dto->getCdPfExecutor()) {
$execDTO = $pessoaFisicaDao->getById($this->dto->getCdPfExecutor());
$executor = $execDTO->getNmPessoaFisica();
$executor_foto = Image::get($execDTO);
} else {
$execDTO = new PessoaFisicaDTO();
$executor = 'Executor não definido';
$executor_foto = Image::get($execDTO);
}
$solicitante = '';
$solicitante_foto = '';
if ($this->dto->getCdPfSolicitante()) {
$soDTO = $pessoaFisicaDao->getById($this->dto->getCdPfSolicitante());
$solicitante = $soDTO->getNmPessoaFisica();
$solicitante_foto = Image::get($soDTO);
}
$ocorrencia = '';
$dt_ocorrencia = '';
if ($this->dto->getCdOcorrencia()) {
/** @var $ocorrenciaDTO */
$ocorrenciaDTO = (new OcorrenciaDAO())->getById($this->dto->getCdOcorrencia());
$ocorrencia = $ocorrenciaDTO->getDescAssunto();
$dt_ocorrencia = (new DateTime($ocorrenciaDTO->getDtOcorrencia()))->format('d/m/Y');
}
$categoria = new CategoriaValorDAO();
$estagio = '';
if ($this->dto->getCdCatgEstagio()) {
$catg = $categoria->getBy2Ids($this->dto->getCdVlCatgEstagio(), $this->dto->getCdCatgEstagio());
$estagio = $catg->getDescVlCatg();
}
$tipo = '';
if ($this->dto->getCdCatgTipo()) {
$catg = $categoria->getBy2Ids($this->dto->getCdVlCatgTipo(), $this->dto->getCdCatgTipo());
$tipo = $catg->getDescVlCatg();
}
$sub_tipo = '';
if ($this->dto->getCdCatgSubTipo()) {
$catg = $categoria->getBy2Ids($this->dto->getCdVlCatgSubTipo(), $this->dto->getCdCatgSubTipo());
$sub_tipo = $catg->getDescVlCatg();
}
$atendimento = '';
if ($this->dto->getCdCatgAvalAtendimento()) {
$catg = $categoria->getBy2Ids($this->dto->getCdVlCatgAvalAtendimento(), $this->dto->getCdCatgAvalAtendimento());
$atendimento = $catg->getDescVlCatg();
}
$qualidade = '';
if ($this->dto->getCdCatgAvalQualidade()) {
$catg = $categoria->getBy2Ids($this->dto->getCdVlCatgAvalQualidade(), $this->dto->getCdCatgAvalQualidade());
$qualidade = $catg->getDescVlCatg();
}
return array('cd_ordem_servico' => $this->dto->getCdOrdemServico(), 'cd_setor' => $this->dto->getCdSetor(), 'setor_dados' => $setorDados, 'cd_ocorrencia' => $this->dto->getCdOcorrencia(), 'desc_ocorrencia' => $ocorrencia, 'dt_ocorrencia' => $dt_ocorrencia, 'desc_assunto' => $this->dto->getDescAssunto(), 'desc_ordem_servico' => $this->dto->getDescOrdemServico(), 'desc_conclusao' => $this->dto->getDescConclusao() ? $this->dto->getDescConclusao() : 'Não informada.', 'cd_pf_executor' => $this->dto->getCdPfExecutor(), 'executor' => $executor, 'executor_foto' => $executor_foto, 'cd_pf_solicitante' => $this->dto->getCdPfSolicitante(), 'solicitante' => $solicitante, 'solicitante_foto' => $solicitante_foto, 'cd_catg_estagio' => $this->dto->getCdCatgEstagio(), 'cd_vl_catg_estagio' => $this->dto->getCdVlCatgEstagio(), 'cd_catg_tipo' => $this->dto->getCdCatgTipo(), 'cd_vl_catg_tipo' => $this->dto->getCdVlCatgTipo(), 'cd_catg_sub_tipo' => $this->dto->getCdCatgSubTipo(), 'cd_vl_catg_sub_tipo' => $this->dto->getCdVlCatgSubTipo(), 'cd_catg_aval_atendimento' => $this->dto->getCdCatgAvalAtendimento(), 'cd_vl_catg_aval_atendimento' => $this->dto->getCdVlCatgAvalAtendimento(), 'desc_aval_atendimento' => $atendimento, 'cd_catg_aval_qualidade' => $this->dto->getCdCatgAvalQualidade(), 'cd_vl_catg_aval_qualidade' => $this->dto->getCdVlCatgAvalQualidade(), 'desc_aval_qualidade' => $qualidade, 'valor_material' => 'R$ ' . number_format($this->dto->getValorMaterial(), 2, ',', '.'), 'valor_servico' => 'R$ ' . number_format($this->dto->getValorServico(), 2, ',', '.'), 'icon_atendimento' => $this->getIcons($this->dto->getCdVlCatgAvalQualidade()), 'icon_qualidade' => '', 'estagio' => $estagio, 'tipo' => $tipo, 'sub_tipo' => $sub_tipo, 'dt_inicio' => (new DateTime($this->dto->getDtInicio()))->format('d/m/Y'), 'dt_fim' => $this->dto->getDtFim() ? (new DateTime($this->dto->getDtFim()))->format('d/m/Y') : 'em aberto');
}
示例13: testSaveSnapshot
function testSaveSnapshot()
{
$obj = $this->objFromFixture('ExtensionData', 'testmodule');
$realUrl = 'http://openbees.org/images/Demo.jpg';
$imageId = ExtensionSnapshot::save_snapshot($realUrl, $obj->Name);
$image = Image::get()->byID($imageId);
$this->assertFileExists(BASE_PATH . DIRECTORY_SEPARATOR . $image->Filename);
}
示例14: addTypeIcon
public function addTypeIcon($row, $label, DataContainer $dc, $args = null)
{
$args[0] = \Image::getHtml(\Image::get('system/modules/mail_to/assets/mail-open-image.png', 16, 16));
$objFile = FilesModel::findByUuid($row['folder']);
$args[2] = $objFile !== null ? $objFile->path : '-';
$args[5] = Date::parse(Date::getFormatFromRgxp('datim'), $row['lastrun']);
return $args;
}
示例15: getResponsiveImage
/**
* Get the path to the resized image
*/
protected static function getResponsiveImage($arrSize, $strSrc)
{
$varImagePath = null;
if ($arrSize[0] > 0 || $arrSize[1] > 0) {
$varImagePath = \Image::get($strSrc, $arrSize[0], $arrSize[1], $arrSize[3]);
}
return $varImagePath;
}