Jump to content

Search the Community

Showing results for tags 'images'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to ProcessWire
    • News & Announcements
    • Showcase
    • Wishlist & Roadmap
  • Community Support
    • Getting Started
    • Tutorials
    • FAQs
    • General Support
    • API & Templates
    • Modules/Plugins
    • Themes and Profiles
    • Multi-Language Support
    • Security
    • Jobs
  • Off Topic
    • Pub
    • Dev Talk

Product Groups

  • Form Builder
  • ProFields
  • ProCache
  • ProMailer
  • Login Register Pro
  • ProDrafts
  • ListerPro
  • ProDevTools
  • Likes
  • Custom Development

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

  1. Hi, I'm struggling with the syntax... multiple galleries, created as repeaters, need an ID to export to JS - to call a gallery script. Everything works so far except the repeater Id, which I don't know how to concatenate to form the #galleryId. This is my hopeless attempt: $repeaterId = $pages->get($repeaterPageID); $galleryId = gallery.$repeaterId; echo "<div id='$galleryId'>"; foreach ... ...
  2. We had a slight problem with ImageSizer recently; everything seemed to be fine but creating thumbnails still failed. The reason for this turned out to be that those images were of unsupported type (windows bitmaps) yet their extension was ".jpg" and thus ImageSizer considered them proper JPEG's and acted accordingly. Anyway, sorry for the spam but this is the solution I ended up implementing. I'd be grateful if Ryan (or someone else who knows the core well) would take a look and tell me if this is a valid solution -- and if it is, I'd like to suggest changing current extension-based "filtering" to something more like this I also took a look at the Upload class / InputfieldFile, but seems to me that implementing proper imagetype filtering there would require a lot of work.. and doesn't necessarily even make sense in that context. --- wire/core/ImageSizer.php (revision 1717) +++ wire/core/ImageSizer.php (working copy) @@ -46,6 +46,12 @@ ); + /** + * Type of image + * + */ + protected $imagetype; + /** * Allow images to be upscaled / enlarged? * */ @@ -67,11 +73,10 @@ * File extensions that are supported for resizing * */ - protected $supportedExtensions = array( - 'gif', - 'jpg', - 'jpeg', - 'png', + protected $supportedImagetypes = array( + IMAGETYPE_GIF, + IMAGETYPE_JPEG, + IMAGETYPE_PNG, ); /** @@ -83,9 +88,10 @@ $this->filename = $filename; $p = pathinfo($filename); $this->extension = strtolower($p['extension']); + $this->imagetype = exif_imagetype($filename); $basename = $p['basename']; - if(!in_array($this->extension, $this->supportedExtensions)) + if(!in_array($this->imagetype, $this->supportedImagetypes)) throw new WireException("$basename is an unsupported image type"); if(!$this->loadImageInfo()) @@ -130,12 +136,9 @@ $source = $this->filename; $dest = str_replace("." . $this->extension, "_tmp." . $this->extension, $source); - switch($this->extension) { - case 'gif': $image = @imagecreatefromgif($source); break; - case 'png': $image = @imagecreatefrompng($source); break; - case 'jpeg': - case 'jpg': $image = @imagecreatefromjpeg($source); break; - } + if($this->imagetype == IMAGETYPE_GIF) $image = @imagecreatefromgif($source); + if($this->imagetype == IMAGETYPE_PNG) $image = @imagecreatefrompng($source); + if($this->imagetype == IMAGETYPE_JPEG) $image = @imagecreatefromjpeg($source); if(!$image) return false; @@ -143,7 +146,7 @@ $thumb = imagecreatetruecolor($gdWidth, $gdHeight); - if($this->extension == 'png') { // Adam's PNG transparency fix + if($this->imagetype == IMAGETYPE_PNG) { // Adam's PNG transparency fix imagealphablending($thumb, false); imagesavealpha($thumb, true); } else { @@ -155,7 +158,7 @@ imagecopyresampled($thumb, $image, 0, 0, 0, 0, $gdWidth, $gdHeight, $this->image['width'], $this->image['height']); $thumb2 = imagecreatetruecolor($targetWidth, $targetHeight); - if($this->extension == 'png') { + if($this->imagetype == IMAGETYPE_PNG) { imagealphablending($thumb2, false); imagesavealpha($thumb2, true); } else { @@ -170,20 +173,13 @@ imagecopyresampled($thumb2, $thumb, 0, 0, $w1, $h1, $targetWidth, $targetHeight, $targetWidth, $targetHeight); // write to file - switch($this->extension) { - case 'gif': - imagegif($thumb2, $dest); - break; - case 'png': - // convert 1-100 (worst-best) scale to 0-9 (best-worst) scale for PNG - $quality = round(abs(($this->quality - 100) / 11.111111)); - imagepng($thumb2, $dest, $quality); - break; - case 'jpeg': - case 'jpg': - imagejpeg($thumb2, $dest, $this->quality); - break; + if($this->imagetype == IMAGETYPE_GIF) imagegif($thumb2, $dest); + if($this->imagetype == IMAGETYPE_PNG) { + // convert 1-100 (worst-best) scale to 0-9 (best-worst) scale for PNG + $quality = round(abs(($this->quality - 100) / 11.111111)); + imagepng($thumb2, $dest, $quality); } + if($this->imagetype == IMAGETYPE_JPEG) imagejpeg($thumb2, $dest, $this->quality); unlink($source); rename($dest, $source); ... and yes, that's output from SVN diff. I hope you guys can cope with that / understand what's going on in there. I'm not very familiar with Git and how it handles stuff like this. Sorry.
  3. I'm building my first brand new Processwire site! It's easy and looks really extensible so I'm excited. However, I have a codeigniter app that is going to eventually sit in a directory beneath Processwire and I want to store assets like css, js, and images in a top-level directory that both CI and PW will access. Right now, I've accomplish this by using tags like `<img src="<?php echo $config->urls->templates ?>../../assets/images/russellbits-logo-small.png" alt="Russellbits"/>` Works fine, but it's messy. Is there another way I could do this in PW without making an http call?
  4. Does anyone know if it's possible to configure the images field to require description text? A fallback would be to write an onsubmit handler in javascript for the admin - but if it's possible to enforce at the configuration level, that seems like a much cleaner solution. EDIT: the core image field is already in heavy use. If possible, I'd like to modify existing instances rather than create a custom field.
  5. Hi! I've just started developing my first PW project (it's great so far! ) and ran into an issue about how to output an thumbnail image: I want to iterate over news items which have an images repeater (field type "image", inputfield type "image") and display resized images: foreach($page->children as $news_item) { ... if (count($news_item->image_repeater)>0) { foreach ($news_item->image_repeater as $image) { <?= $image->width(250)->url; ?> <img src="<?= $image->width(250)->url; ?>" width="250" alt="" title="<?= $image->description ?>" /> } } } I get an $image returns an ID. The "image" fieldtype has the setting maximum files allowed = 1 (0 didn't work too). PW Version 2.2.13. Any idea? Thx
  6. I want to resize an image that is included in a selected featured project as referenced from a Home page. The "Featured Project" field found on the Home page is using a Page type. The "Images" field included in the "Featured Project" is a repeater field that includes an Image field. How do I access the first image in the "Images" field and also resize the image? This works and returns the ID of the image: $img = $page->featured_project->images->first(); but this doesn't work to resize the image: $img = $page->featured_project->images->first(); $thumbnail = $img->size(236,225); Nor does this: $img = $page->featured_project->images->first()->size(236,225); Any insight is appreciated!
  7. It would be nice to be able to turn upscaling off (set it to false on ImageSizer) via size() function of Pageimage. Currently size accepts two parameters (width, height) -- how 'bout adding upscaling (true/false, default to true.. or perhaps "disable upscaling" and default to false, whichever makes more sense) as third parameter?
  8. Hello everyone, I've run into a issue with the way Processwire renames resized files in our company host provider. Basically, this pattern: myfile.0x120.png, conflicts with their security policy which they tag with the following classification: [severity "CRITICAL"] [tag "WEB_ATTACK/SQL_INJECTION"] So, somehow, when requesting a file with the pattern above, the server mistakes it for a malicious request and throws a 403 Forbidden Access. The quickest solution I've found for this was to dive into the Pageimage::size method and replace the characters used in the resized file name. Instead of using double periods in the name file, I've replaced everything with the '-' (hyphen) character and now looks like this: myfile-0-120.png. $basename .= '-' . $width . '-' . $height . "." . $this->ext(); // i.e. myfile-100-100.jpg It's not the prettiest pattern and I liked the older one better but that's secondary. The main issue here is that this change is basically an hack and feels dirty changing core methods, but it was the quickest solution I've thought of. What are your feelings on this?
  9. Hi guys, am having a problem with uploading images within a repeater field. I'm just getting a little image icon and the fields aren't getting populated. I'm using the latest dev branch, so not sure if it's a possible issue with that. Can anyone else replicate this? I have included a screenshot. Thanks!
  10. I'm trying to plan out a portfolio site that gives me some room to grow. I've read a lot of questions and answers on the forums regarding how to set up images for portfolio sites. Which method is the most future-proof: adding images to a page with the image field, adding images to a page using repeater fields for extra data (a proper title, tags, etc.), or giving each image its own child page and adding fields to hold any extra data? They each have their pros and cons; which method would the ProcessWire veterans recommend? Ryan linked this site on twitter: http://www.villasofdistinction.com/. He mentioned it had ~30k photos. Ryan, what method did you use? Thanks!
  11. Hi, I've just started learning ProcessWire. Something seems plain but doesn't work as I expect, images e.g. I checked out that home template has images field, then I edited a home page based on that template and tried to upload an image. I selected a file then clicked submit and the file name appeared in the image field. Only filename appeared, but not a thumbnail. When I pressed save button I got a success message but in the image field the filename disappeared and there was no image too. It goes same way if I grag and grop image file. What should I fix to upload images to a image field? ps I run ProcessWire with Nginx, could it be the cause of broken image upload?
  12. Hi, I'm trying to output an image description with 2 lines, and have been able to get Markdown to do this on the output, however the Markdown formatter is adding a paragraph tag... is there some other good way to output an image description with a line break? thanks, -marc
  13. Hi there, Wonder whether someone can explain something I'm seeing. I started out with an image field type - no repeater. I could access an individual image object reference, point to it's "url" property and I had a path to the image. When the image field is in the repeater, I see the following value: $repeater->images->url = /ProcessWire/site/assets/files/1009/ When I look in this folder, I see the image that I want, and also, another image that in this case is called "gina-bg-2.0x100.jpg" - the one I actually added was "gina-bg-2.jpg". So, firstly, I don't know where the x100 version of the image has come from? Secondly, I want to get the full url path to gina-bg-2.jpg but I cannot seem to see a way of directly referencing it now the image is inside the repeater? $repeater->images is a "Pageimages" type reference. How can I access each contained Pageimage? If I specify $image->images[0], I get a "Page" type and not the Pageimage that I expect. Any ideas appreciated! Thanks --Gary
  14. Hi there, In the home page (and indeed elsewhere) of the first site I'm building, there are a range of images. Some of the images are dedicated to a carousel, others are for different places in the home page. I could obviously add all of the images to the "images" field. The image field type provdes Label and Description values. However, I will want to query all of images that should be used in the carousel to write out in a loop. So, this is an additional "property" to group by. I might also want to order the images in the carousel group by an integer so they appear in the correct or user-defined sequence. This is therefore another additional property. I suppose I could create a second field based on image fieldtype called "carousel" and then I know it contains only the carousel images. However, I still want to have the ability for the end user to specify an order in the control panel. Clearly, this could be achieved using a single image field where the images have a naming convention. However, this would be very brittle from the end user's POV. The question boils down to best practice in this scenario? I could see this being a "repeater" use-case where the extra properties are part of the repeater item. Before I do this, I wonder whether anyone could advise if this sounds like a good approach or, is there something I'm missing, like somehow extending the image module to include these values as I can see this being a requirement time and again. Thanks! --Gary
  15. Hi there, In ExpressionEngine (EE), you can define target upload folders and specify what can be uploaded. For now, my main area of concern is images. In your templates, you can then specify the upload folder for image placement. In EE, when you upload an image, you can also specify a list of additional named "actions" against the original upload that will, for example, create different versions of the images at different sizes. So, with a single image upload, you would have the original full size image, maybe a "thumbs" folder with a userdefined thumbnail size, and perhaps a "medium" folder with the image at 50% of its original size. This is really flexible and I wondered whether there is anything like this in PW or how you would routinely achieve this kind of thing? Many thanks.
  16. Hello, I'm really sorry to ask you this kind of very simple question, I'm discovering processwire and have not so much php knowledge. Until know I'm able to get the data from text fields without any problem and that's great But have some problem with multiple images. I've read a lot but didn't find the solution by myself so here am I. How can I display multiple images from the same images field? That's basically my question. My code: <?php foreach($page->children as $project) echo "<h2>{$project->title}</h2> <p>{$project->body}</p> <img src='{$project->images->url}'>"; ?> http://catalanotto.ch/processwire/print/ For know the images isn't displaying (seems the path isn't ok) and it's just displaying one image result. If it helps, more informations: I have pages like that: category > project > project > project category >project >project In the project page and template I use the images field provided by default with the processwire installation. There I have one or more images. Thanks for reading and hope I'm not bothering you too much with this very simple question.
  17. Hi everyone, I would like to target the last image in the fieldset and apply a specific class to it. How would I do that? I've tried this and it applies it to all: if(($page->images->last()->name) == 'whatsnext.png') { echo $whatsnextclass; } It's not targeting that specific image, it's just checking to see if that exists. I don't know how else to go about this. Help please? Thanks!
  18. I've been working on an automating an import of some pages. For all intents and purposes, it's basically a form submission to a module process that creates/updates a page of a certain template. For the literal minded, I'm importing an existing news archive (headline, story, byline, image) by scripting the form submission. So far, everything has worked great, and I can update the text/textarea fields without any issues, but I'm not able to figure out how to attach an image in the $_FILES superglobal to the $page object. I suspect my thinking on how to do this is backwards, and there may be an API method that handles some of the lifting - but I don't mind getting my hands dirty either if I need to code it closer to the metal. I've starting to look at the FieldtypeImage source and the inheritance thereof, but I'm starting to find myself out in the weeds. Does anyone know of a way to affix an uploaded image (outside of the page admin) to a $page object? The input handling of the submission currently looks a little like this: foreach($page->template->fields as $template_field){ $field_name = $template_field->name; $field_class = $template_field->type->className; $update_value = $this->input->post($field_name); switch($field_class){ case 'TitleFieldtype': case 'TextareaFieldtype': $page->{$field_name} = $update_value; break; case 'ImageFieldtype': // <----- the confounder // not sure what to do here if the field // if name is represented in $_FILES break; ... } ... } EDIT: Simplified code block.
  19. Hi, I tried installing the thumbnail module and when adding images in fields found that the bar went straight to 100% and the images didn't show so I uninstalled it and it deleted the cache and images seemed to work again but unexpectedly I'm now having the same problem again. Not sure how to either re-install or re-uninstall (?) to get things back to normal! Not sure if Apeisa can help out? Would be appreciated and sorry to be posting every 5 minutes! I feel the next day or two is make or break for me with PW!
  20. Another error Following code: $page->images->removeAll(); $page->images->add($commitsGraphSrc); $page->images->add($languagesGraphSrc); $page->save(); $page->images->eq(0)->rename('commits-graph-'.substr(date('now'),0,4).'.png'); $page->images->eq(1)->rename('languages-graph-'.substr(date('now'),0,4).'.png'); $page->save(); should delete all images if any, add two new images, save the page, and then remove the images to something sensible from the google chart URL (because $..GraphSrc is google chart api URL). And the delete fails horribly with following: [b]Fatal error[/b]: Exception: Invalid type to Pageimages::remove(item) (in /Users/adam/Sites/this.is.secret/wire/core/Pagefiles.php line 182) #0 /Users/adam/Sites/this.is.secret/wire/core/Array.php(653): Pagefiles->remove('commits-graph-1...') #1 /Users/adam/Sites/this.is.secret/site/templates/github.php(103): WireArray->removeAll() #2 /Users/adam/Sites/this.is.secret/wire/core/TemplateFile.php(92): require('/Users/adam/Sit...') #3 [internal function]: TemplateFile->___render() #4 /Users/adam/Sites/this.is.secret/wire/core/Wire.php(267): call_user_func_array(Array, Array) #5 /Users/adam/Sites/this.is.secret/wire/core/Wire.php(229): Wire->runHooks('render', Array) #6 /Users/adam/Sites/this.is.secret/wire/modules/PageRender.module(236): Wire->__call('render', Array) #7 /Users/adam/Sites/this.is.secret/wire/modules/PageRender.module(236): TemplateFile->render() #8 [internal function]: PageRender->___renderPage(Object(HookEvent)) #9 /Users/adam/Sites/this.is.secr... in <b>/Users/adam/Sites/this.is.secret/index.php on line <b>203</b> Also, if it;s something, I'm not totally sure why calling $this->remove() in the Array does Pageimages::remove... or why the $item in chekcing isValidItem is string and not pageimage.
  21. Hey all, I'm trying to add dynamically generated Google Chart Image to image field, but... it doesn't work $imgSrc = 'https://chart.googleapis.com/chart?chs=920x200&cht=bvs&chd=t:0,7,0,0,4,0,0,0,0,0,0,1,0,0,0,1,2,0,0,0,7,11,4,0,3,4,2,4,6,1&chds=a&chm=B,eeeeee,0,0,0&chls=3&chco=222222' $page->images->add($imgSrc); It fails with 'Exception: Unable to copy: ' and adds a bunch of data. I've got two questions: How can I affect the filename of the file created [thus add some extension, for instance it's PNG file]. And more importantly, why doesn't this work? I know for a fact that URL adding works. Edit: Actually, this is how I save this: $page->images->removeAll(); $page->images->add($commitsGraphSrc); //it's an URL for google chart API $page->images->add($languagesGraphSrc); //another URL for gchart API $page->save();
  22. Is it possible to get an image scaled down proportionally, like for example, I need it to fit in a 400px box (no height constraint). And the images might have different heights that would respond to the given constraint? Right now it seems I need to specify the width and height of the image that it placed, but the problem is I have images of different sizes and proportions.
×
×
  • Create New...