Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/11/2015 in all areas

  1. I definitely go with PWs API first. I always follow the strategy that the original uploaded image never gets outputed as is. Therefore I'm able (and it is highly recommended) to upload images with full quality! (Photoshop JPEG: Quality = 12) You need to keep full quality (PW: quality = 100) for every intermediate step. Only with the last step, that produces an image for output, you need to apply a lower quality setting, e.g. 80. Example manipulation with watermarking, (using PW API with PageimageManipulator): // create ImageObject from fullsize WatermarkImage $wmPng = $pages->get('/mytoolspage/')->watermark; // create a fullsize image with watermark and quality 80! (the global $config->imageSizerOptions quality is set to 80, so don't need to set it here again individually) $image->pimLoad('full')->watermarkLogo($wmPng)->pimSave(); // create a medium sized image with watermark and quality 75! $wmPngMedium = $wmPng->width(960, array('quality'=>100)); $image->width(960, array('quality'=>100))->pimLoad('medium')->watermarkLogo($wmPngMedium)->setQuality(75)->pimSave(); // create a small sized image with watermark and quality 68! Now we first apply the (full) watermark and scale down afterwards: $image->pimLoad('small')->watermarkLogo($wmPng)->setQuality(100)->pimSave()->width(480, array('quality'=>68)); . If you want apply those or other manipulations direct on upload, you can go this way: // is called on hook: addHookBefore 'InputfieldFile::fileAdded' public function prepareUploadedImage($event) { $inputfield = $event->object; if ('images' != $inputfield->name) return; // we assume images field !! name of the field is: images !! otherwise change it $p = $inputfield->value['page']; // get the page if ('album' != $p->template) return; // don't do it on other pages than albums $image = $event->argumentsByName("pagefile"); // get the image // do the image manipulations $image->size(900, 600); $image->size(600, 400); $image->size(300, 200); ... } If you want to apply the watermarks on uploading, you have to use the identical API calls in the autoload module than you do in the templates: // is called on hook: addHookBefore 'InputfieldFile::fileAdded' public function prepareUploadedImage($event) { $inputfield = $event->object; if ('images' != $inputfield->name) return; // we assume images field !! name of the field is: images !! otherwise change it $p = $inputfield->value['page']; // get the page if ('album' != $p->template) return; // don't do it on other pages than albums $image = $event->argumentsByName("pagefile"); // get the image // do the image manipulations $image->size(900, 600); $image->size(600, 400); $image->size(300, 200); // create ImageObjects from WatermarkImage $wmPng = wire('pages')->get('/mytoolspage/')->watermark; $wmPngMedium = $wmPng->width(960, array('quality'=>100)); $wmPngSmall = $wmPng->width(480, array('quality'=>100)); // create variations with watermark $image->pimLoad('full')->watermarkLogo($wmPng)->pimSave(); $image->width(960, array('quality'=>100))->pimLoad('medium')->watermarkLogo($wmPngMedium)->pimSave(); $image->width(480, array('quality'=>100))->pimLoad('small')->watermarkLogo($wmPngSmall)->pimSave(); } . You can also use Pia within those chains if you like to use one of her shortcuts: $image->contain("square=1200, quality=100")->pimLoad('max1200')->watermarkLogo($wmPng)->setQuality(75)->pimSave(); . Summary: upload quality = 100% every intermediate quality = 100% final quality = is the only quality lower than 100% This way you produce very fine images, even with GD-lib.
    5 points
  2. This doesn't even need an instance of TemplateFile. $text = wireRenderFile("views/text", array( "id" => $page->id, "title" => $page->parent->title )); // /views/text.php echo "This page has $id and its parent title is $title"; Edit:If you're looking to provide the template as string there's this: https://github.com/ryancramerdesign/ProcessWire/blob/576a5d30153f045daa94a136a6ba981650632b26/wire/core/Functions.php#L855
    4 points
  3. Just bumped into this nice little article from last year. I, too, would like to share PW with fellow South Africans, which I'll be doing when I release my new website in the coming months. Here's the article: jansieblom.co.za/perfect-cms/
    3 points
  4. I released a simple module: Processwire Dice Captcha Module This is a very simple captcha module. For more extensive information please read the REAMDE on github. If you want you can change the jpg files and adapt the size setting in the module accordingly. This should also increase security as if you use more complex images they will be harder to recognize. You can als change the number of dices asked for. Usage: <?php //Init Module $dice = $modules->get("FormDiceCaptcha"); //On submit check if the validation is correct if($input->post->submit) { //validate - the value is stored in the session if(!$dice->validate($input->post->captcha)) echo "<p class='error'>".__("Please check that you have completed all fields")."</p>"; else echo "Success!"; } ?> <form method="post" action="./"> <!--Show captcha --> <img src="$dice->captcha()"/> How much is the sum of the dices? <!--ask for sum --> <input type="text" name="captcha" value="$form[captcha]"/> <input type="submit" name="submit" value="submit"> </form> Github: https://github.com/romanseidl/FormDiceCaptcha Changelog 0.1.1 Changed the directory structure to conform with Processwire standards and renamed the module classname to FormDiceCapture to conform naming conventions. Also the github project had to be renamed. In case you have version 0.1.0 installed you will have to change the calls to $modules->get('DiceCaptcha') to $modules->get('FormDiceCaptcha') after updating to 0.1.1.
    2 points
  5. Here you go: https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/core/Functions.php#L855
    2 points
  6. By default, the "Forgot Password" module is not turned on in v2.1. My thought was that lack of such a function is technically more secure (on any site or CMS). Why? Because having such a function active means your password is only as secure as your email (*though see note at end of this message). So I thought we'd start things out as secure as possible and let people adjust it according to their own need. But I'm rethinking that decision, and may change it to be 'on' by default. If you don't already have that "Forgot Password" module installed, it is relatively easy to reset your password with the API. Lets say that you lost the password for your account named 'admin' and you wanted to reset it. Paste this code into any one of your templates (like /site/templates/home.php in the default profile, for example): <?php $admin = $users->get('admin'); $admin->setOutputFormatting(false); $admin->pass = 'yo12345'; // put in your new password $admin->save(); …or if it's easier for you to copy/paste everything on one line, here's the same thing as above on one line: <?php $users->get("admin")->setOutputFormatting(false)->set('pass', 'yo12345')->save(); Replace "yo12345" with the new password you want and save the template. Then view a page using that template (like the homepage, in our example). The password for that account has now been reset, and now you are ready to login. Don't forgot to now remove that snippet of code from the template! Otherwise your password will get reset every time the page is viewed. Once logged in, here's how to install the Forgot Password capability: 1. Click to the "Modules" tab. 2. Scroll down to the "Process" modules. 3. Click "Install" for the "Forgot Password" module. That's all there is to it. You will now see a "Forgot Password" link on your login page. *ProcessWire's "Forgot Password" function is actually a little more secure than what you see in most other CMSs. Not only do you have to have the confidential link in the email, but the link expires in a matter of minutes, and PW will only accept password changes from the browser session that initiated the request. So an attacker would have to initiate the password change request and have access to your email at the same time, making it a lot harder for a man-in-the-middle snooping on your email.
    1 point
  7. @valan Have a look at my added link in the edit.
    1 point
  8. A quick test shows it works fine for me with GD if I use 24bit PNG with transparency as overlay. I used this code for the final image: $img->crop("width=300, height=200, quality=100")->pimLoad('graywm')->setQuality(90)->grayscale()->watermarkLogo($wm, 'c', 0)->save()->url original image cropped via pia + = using Pim to grayscale + transparent png overlay with colored area the result looks good to me ---- Going one step further and using a pure grayscale overlay (with gray area, not a blue one) enables to change the color on the fly and produce different outputs: $color1 = array(100, 100, 0); $wmColor1 = $wm->pimLoad('color1')->setQuality(100)->grayscale()->colorize($color1)->save(); $img->crop("width=300, height=200, quality=100")->pimLoad('color1')->setQuality(90)->grayscale()->watermarkLogo($wmColor1, 'c', 0)->save()->url original + grayscaled using Pim + overlay in gray final image with yellow colorized overlay ------- @Pierre-Luc: maybe there are parts I'm not aware of in your case, but GD isn't that bad in many regards. So, it is very bad in regards of transients and smooth transparencies when it comes to dynamically create and overlay parts. EDIT: Ah, sorry, I have not looked / read very thoroughly your post. You want use composites with modes and that isn't handled at all by GD. It is not a simple overlay with transparency.
    1 point
  9. you mean something like passing a variable to a template the way Views are rendered in MVC frameworks try the TemplateFile Class <?php // this is your template file, or a controller if you will: $view = new TemplateFile(); $view->some_param = "PW"; $view->filename = $config->paths->templates."views/{$page->template}.php"; echo $view->render();
    1 point
  10. Thanks a lot for your input, I'll find a way to make it happen. My use case is a bit different though, and GD's limited abilities to composite images with modes will probably exclude it, but you give me a good idea how to tackle the problem!
    1 point
  11. ok - so for the custom menu, the way i did it in the past on many sites was with a hidden branch of the page tree, usually underneath a page called Settings; Most sites i build do require the menu to be very specific and there is absolutely no way that the menu displayed in the front end can be based on the page tree; in my opinion, the page tree being used as the front end menu is only for very small and simple sites; anything more complicated requires you to build your own menu, and now that we have Kongondo's menu module, this is even easier than ever. If you take a look at that module, there may very well be a way to assign a custom URL override to any menu item; i have not tried it yet, but i am planning on using it for the next site i release which is now in admin development. once you have made your menu page tree (yes manually, one by one), and on each of those items selected the page that the menu item will link to, you can use that code to output your menu, and modify it to your needs in terms of menu markup. You can also configure the override field to be always used if it is populated. If you wish to use the page tree as-is to generate your menu, that is pretty much the same thing; you just need a field to override the page's URL in the menu and then use your output code to check if that field is populated and swap out the value of that field with the default URL of the page.
    1 point
  12. Hi Andi, 1) Thanks for the links and for the useful part of the informations. 2) I (personally) allready haveused GraphicsMagick a year ago. In the above post it was said in the past (at least I tried to do so). Besides that: I have used a lot of other image processors in the past 15 years too. But I cannot see any usefullness with installing a software that only integrates image processors. If I want to evaluate the quality of image processors, I use the image processors. 3) GraphicsMagick does a (maybe very) good job, but IMHO it isn't the best tool out there. The best tool in regard of visually quality for photos is NETPBM! - if one know how to use it. 4) And sorry if I have posted in a way that not let you see what I have meant in the first place. What I have tried to do with the imagickresizer, and also have tried to say in the newer posts here, was to bring in a next step of image processing for a wide range of users. It should not only be available for those who are on their own servers. So using apt-get install... isn't an option for all that are not on their own servers. 5) Please do not assume what I have done, nor what I have done not. This is neither purposeful nor pleasing to read. My short and precious free time I like to spend rather different. Maybe with programming something (or doing other) that is useful for PW and a wide range of PW-users. 6) I'm available for paid PW modules development. I allready have built some nice custom ones in regard of image processing. Horst
    1 point
  13. Not really such a big deal, but.. this made me smile. Perhaps Ryan could implement couple of vulnerabilities somewhere, so that we can get some CVEs of our own?
    1 point
  14. Hi Matthew, Commas need to be escaped because they are also used to separate fields in the Selector. The correct method is this: $np->title = $sanitizer->selectorValue($input->post->title); You should sanitize all values that you use in a selector like this. Use text(), textarea() when you are outputting your data on the website, e.g. in form fields. Btw you are right, Pw does set a name based on the title if you ommit setting ->name. Cheers
    1 point
  15. hi ryan, this piece is by former modx fanboys, who converted to pw recently. it's made in interview style and the guy who is mainly talking had pw on his shortlist for a while. since pw was awarded by cmscritics recently, they now decided to publish the interview. their first topic is how easy it is to update pw compared to modx. they continue with their opinion, that modx is more "academic" while pw is made by people who know webdesigner's everyday business. next they praise how responsive the main developer of pw is (do you know him?). good ideas raised in the forum make their way into the core quickly, they state. next they talk about the simplictiy of pw. they raise questions on the roadmap: will pw stay as simple as it is? or will it go the "enterprise road" like modx did? the piece is not at all an introduction to pw. it's more a fireside chat of people who know modx in detail and now compare it to pw. they end with a chat about the api. that everything in pw has to bee done "manually" in pw (with some php knowledge), is a major advantage from their point of view. however, they consider pw as not "sexy" but powerful. the whole thing is a bit like pirate radio (do you say so in english?). i mean independent radio by amateurs. cheers, christoph
    1 point
×
×
  • Create New...