Jump to content

horst

PW-Moderators
  • Posts

    4,077
  • Joined

  • Last visited

  • Days Won

    87

Everything posted by horst

  1. Martijn, sometimes I need some more headers, if not already set with apache or to override the apaches default. Maybe you find it useful. // collect infos $maxAge = (60 * 60 * 24 * 2); // 48 hours $imgTimestamp = filemtime($imgFilename); $imgExpiration = intval(time() + $maxAge); // create headers $imgHeaders = array(); $imgHeaders[] = 'Content-type: image/jpeg'; // or other type $imgHeaders[] = 'Content-Length: ' . filesize($imgFilename); $imgHeaders[] = 'Date: ' . gmdate('D, d M Y H:i:s',time()) . ' GMT'; $imgHeaders[] = 'Last-Modified: ' . gmdate('D, d M Y H:i:s',$imgTimestamp) . ' GMT'; $imgHeaders[] = 'Expires: ' . gmdate('D, d M Y H:i:s', $imgExpiration) . ' GMT'; $imgHeaders[] = 'pragma: cache'; $imgHeaders[] = "Cache-Control: max-age={$maxAge}"; //$imgHeaders[] = "Cache-Control: no-transform, public, s-maxage={$maxAge}, max-age={$maxAge}"; // public|private // send header foreach($imgHeaders as $imgHeader) header($imgHeader);
  2. That's the way I have done it. Now I am searching if / how it is possible to create another parallel branch (separate). On the Github website the (auto) forked repo has a "branch-1". I would like to have a "branch-2" too: forked-repo-| | |---- branch-1 (with changes) | |---- branch-2 (with other changes) Did someone know how to do it (directly on the GitHub website if possible)?
  3. An overview and tuto: http://www.devshed.com/c/a/PHP/Creating-a-PHP-PayPal-Instant-Payment-Notification-Script/
  4. This point I want double-like! (but it isn't an available feature)
  5. SELECT name,modified,modified_users_id FROM pages WHERE id=2
  6. I don't really know about that but have little intuition that it could have to do with the fact if one has already filled some fields of a repeater record but hasn't saved the page. Maybe these 'predefined' and than half 'prefilled' repeater records could have to do with it?
  7. Hi J1312, but this must work too! I haven't a 2.3 stable version installed here, only latest dev, so I cannot test. But it sounds not logical. What are the dimensions of the original image and what is the setting for upscaling? Maybe a typo in $options, please use: size( 80, 90, array('cropping'=>false, 'upscaling'=>true) ); OH, blink-blink: you also should use removeVariations() first, while testing. please use: $image = $page->images->first(); if($image) { $image->removeVariations(); // otherwise it may take a previous cached version instead of create a new one echo "<img src='{$image->size( 80, 90, array('cropping'=>false, 'upscaling'=>true) )->url}' />"; }
  8. Oh, sorry I have missread your post. I've thought using header set with only one value has worked. I think you first have to check if mod_headers is available.
  9. no - I've thought the theoretic way is to search via google or at apache: http://httpd.apache.org/docs/current/mod/mod_headers.html under examples 6)
  10. hhm, I'm not sure with apache stuff, but I think its some kind of wrong syntax. If you are more pragmatic then theoretic (like me), you may try: Header append Cache-Control "no-transform" Header append Cache-Control "private" and look if/what headers are sent.
  11. @vxda: and of course, for resizing you don't need the Pageimage Manipulator. It is enough to call ->width() on a pageimage: // example $pageimage = $myNewsItem->images->first->width(313)->url; But also your variable names are a bit confusing: your variable $pageimage contains only the URL. I would change this to avoid confusion: // example $pageimage = $myNewsItem->images->first->width(313); // and then $out .= "<img src='{$pageimage->url}' alt='' />"; References on how to work with images: http://processwire.com/api/fieldtypes/images/ http://processwire.com/tutorials/quick-start/images/ http://processwire.com/talk/topic/10-how-do-i-interact-with-the-image-field-in-processwire/
  12. If you don't want that in some particular situations, you can use HTTP-Header like Cache-Control "no-transform" for images! http://mobiforge.com/developing/story/setting-http-headers-advise-transcoding-proxies
  13. @RJay: yes that's right, - but also it is right that if you want to keep proportions and want that they fit into max dimensions for width *and* height you can call: size( $myMaxWidth, $myMaxHeight, array('cropping'=>false) ); For example: http://nogajski.de/priv/postings/rearrangedImageSizer.html#sizeNoCrop & http://nogajski.de/priv/postings/rearrangedImageSizer.html#sizeCrop
  14. Uuups, I haven't thought about that, but that's right. It would make it more confusing than it would help. That was exactly the intention of my post. I'm not totally sure but it looks to me that the possibilities with the options are not well known. Maybe bit more by coders than by designers, (- just to feed a prejudice). I have thought with the possibility to call a single option just before size is called could make it easyier | simpler | more popular.
  15. Hi Martijn, can you only use gif? (Newsletter with embedded cid: ?) You may try: function pimPng2Gif($im1, $rgb) { imagealphablending($im1, true); imagesavealpha($im1, false); $w = imagesx($im1); $h = imagesy($im1); $im2 = imagecreatetruecolor($w, $h); imagealphablending($im2, true); imagesavealpha($im2, false); $bg = imagecolorallocate($im2, $rgb[0], $rgb[1], $rgb[2]); imagefilledrectangle($im2,0,0,$w-1,$h-1,$bg); imagecopy($im2,$im1,0,0,0,0,$w,$h); imagedestroy($im1); return $im2; } $rgb = array(219,17,116); $png = $page->images->first()->pimLoad('png2gif',true); $gif = $png->setMemoryImage( pimPng2Gif($png->getMemoryImage(), $rgb) )->setOutputformat('gif')->save(); echo "<img src='{$gif->url}' /> {$gif->name}";
  16. Thanks both (Ryan and interrobang)! Just have added optional support for PiM-Variations too <pre><?php $keepThumbnails = true; $keepPimVariations = true; // Pageimage Manipulator Variations ini_set('max_execution_time', 60 * 5); // 5 minutes, increase as needed include("./index.php"); if($keepPimVariations) { if(!wire('modules')->isInstalled('PageImageManipulator')) { $keepPimVariations = false; } else { // PiM is installed, but is it a version that has method getPimVariations() (Ver 0.1.0 +) $a = wire('modules')->get('PageImageManipulator')->getModuleInfo(); $actual = preg_replace('/(\d)(?=\d)/', '$1.', str_pad("{$a['version']}", 3, "0", STR_PAD_LEFT)); $keepPimVariations = version_compare($actual, '0.1.0', '<') ? false : true; } } $dir = new DirectoryIterator(wire('config')->paths->files); foreach ($dir as $file) { if ($file->isDot() || !$file->isDir()) { continue; } $id = $file->getFilename(); if (!ctype_digit("$id")) { continue; } $page = wire('pages')->get((int) $id); if (!$page->id) { echo "Orphaned directory: " . wire('config')->urls->files . "$id/" . $file->getBasename() . "\n"; continue; } // determine which files are valid for the page $valid = array(); foreach ($page->template->fieldgroup as $field) { if ($field->type instanceof FieldtypeFile) { foreach ($page->get($field->name) as $file) { $valid[] = $file->basename; if ($field->type instanceof FieldtypeImage) { foreach ($file->getVariations() as $f) { $valid[] = $f->basename; } } // keep thumbnails: if ($keepThumbnails && $field->type instanceof FieldtypeCropImage) { $crops = $field->getArray(); $crops = $crops['thumbSetting']; $crops_a = explode("\n", $crops); // ie. thumbname,200,200 (name,width,height) foreach ($crops_a as $crop) { $crop = explode(",", $crop); $prefix = wire('sanitizer')->name($crop[0]); $valid[] = $prefix . "_" . $file->basename; } } // what's about PimVariations ? if ($keepPimVariations) { if ($field->type instanceof FieldtypeImage) { foreach ($file->pimLoad('x',true)->getPimVariations() as $f) { $valid[] = $f->basename; } } } } } } // now find all the files present on the page // identify those that are not part of our $valid array $d = new DirectoryIterator($page->filesManager->path); foreach ($d as $f) { if ($f->isDot() || !$f->isFile()) { continue; } if (!in_array($f->getFilename(), $valid)) { echo "Orphaned file: " . wire('config')->urls->files . "$id/" . $f->getBasename() . "\n"; // #unlink($f->getPathname()); } } wire('pages')->uncache($page); // just in case we need the memory }
  17. Hi Martijn, sorry, in a previous version this has worked, but by rewriting for rgba support I must have broken it. I have pushed an update to github that solved the issue. But I think the result from converting transparent png to gif isn't what you expect Because transparency get not transformed into GIF-Palette-Color. It seems this isn't possible, - at least not that simple. ?? But bug is fixed now, thanks for your help!
  18. @maba: I use last update too and everything is fine. The div containing the thumb links and images is: <div class="ui-widget-content crops"> it has overflow set to hidden. The thumbnail images have a css z-index: 999, - maybe some other settings have overwritten something? You run any admin theme? Any other admin modules installed?
  19. When working with Pageimages and one don't want to use the default options the coding possibilities should be enhanced. For example, if you are working with the default settings from site/config.php, the setting for cropping is true! If you want to limit the maxlength of mixed images (landscape and portrait) for now you have to do it like this: $img = $page->images->first(); $options = array('cropping'=>false); echo "<img src='{$img->size(500,500,$options)->url}' alt='' />"; We have to use an options array. - But I think it is more straight forward if we could call it like this: $img = $page->images->first(); echo "<img src='{$img->setCropping(false)->size(500,500)->url}' alt='' />"; If we can use these setters like they are available in ImageSizer (setCropping, setUpscaling, setQuality, setSharpening, setAutoRotation) together with Pageimages, the coding-flow feels better and also readability is better What do you think? ------ If this is found to be useful theres not much to do to achieve that. The pageimage class only needs some wrapper methods to store the individualOptions. These get merged together with the default-, config- and direct passed options. Thats all. I have tested this and here are the code snippets I use: And the complete file is here:
  20. Hi Vineet, I have no knowledge about session_timeout. But when reading your post, another solution comes to my mind. Why do you not store the temporary data into the users history pages? Somehow signed as "pending aproval" together with a timestamp? Then there is no need for extra temp_pages or using & tweakin sessions. Maybe more secure, less data overhead and less coding. This way the data must not be deleted after 5 minutes. Its enough that it is only valid for 5 minutes. You may delete such records when come along that users pages the next time (needs only a (few) line(s) of code I think). EDIT: But if you want to delete those data by regular intervals, you may use lazy-cron running onto all "pending-aproval" pages. Just my 2cents.
  21. BTW: the intended way I think is to call size instead of width or height, but with disabled cropping: $image = $page->images->first(); $options = array('cropping'=>false); echo "<img src='{$image->size(900,900,$options)->url}' alt=''>";
  22. EDIT: complete file is here ----------------------------------------------------------------------------------------------- Ryan, I cannot create a second PR at GitHub, so I add the rewritten code as zip attachment here. And it is really good that you will understand it in full after merged it. Because, also if I'm not on vacation (lets say 6, 7 months ago) I'm not sure if I will remember right all the things. So, I have added few more comments to it. BTW, these page about gamma errors is awesome. I have done the test with my Photoshop CS6 Extended localized german for nearly 2k € (if not an upgrade) - and it fails completly with 8bit images. I only get the grayish result with some colored blurriness like in the examples of the site. The short story is: try to scale this prepared image at 50% with whatever software you want. How does your result look? Like this one: or like this one: If you want to know why and how, pleas look here: http://www.4p8.com/eric.brasseur/gamma.html#introduction
  23. @Marty: thanks! Have you seen the post about PiM working together with Thumbnails too? I think you will like it! At least you are responsible for the existence of the Thumbnails Module. ( and yes, - Antti is responsible too) I'm very new and inexpertly with GitHub, because of that I have asked owzim if he can help me to send a pull request to Thumbnails repo with only code for sharpening support. While talking/writing about that GitHub stuff - we also come to conclusion that Thumbnails needs recreation of previously used thumbs. And as I don't know the JS stuff, owzim seems to know it very well and he wrote it! I really like that community here and also how good people work together to make things good and better. Thank you!
×
×
  • Create New...