PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Image watermark after uploading post image

  1. schott19
    Member

    I realise that gravityfroms will not add a watermark to an image when uploading an image via a "post" form (which will go in as a draft post) but what i wanted to know is if i used a standard plugin to watermark an image would this work with the way gravityforms works or would the watermatking plugin get bypassed?

    Also, anybody know of a good watermarking plugin?

    Really hope this is possible as gravity forms is perfect in every other way!

    Thanks

    Posted 14 years ago on Thursday November 25, 2010 | Permalink
  2. best approach would be to watermark it outside of GF. Use the GF form to upload the image(s) and when you output the images to the front-end (so the user can see) call the watermark script, or write your own with the PHP GD library.

    Posted 14 years ago on Thursday November 25, 2010 | Permalink
  3. mmtrav
    Member

    I've set up a watermark plugin that only works when I upload an image through the Wordpress media uploader on a post, not when I send it through the gravity form onto the custom post type for the photos.

    The watermark plugin's documentations had me insert a function in my media.php file of the Wordpress admin (bad practise I know) but that does make me think I could write a code snippet that will trigger the watermark function after submission by gravity forms.

    Ideally I would like the uploaded image to be processed by the watermark script and then also by the theme so it could go straight to publication without me handling it.

    the watermark plugin function was

    // INSERT HERE!!!
    	MM_Execute_WM($file,'');

    could I get a code snippet that will cause the watermark script to process the file sent by gravity forms? that would make my day.

    cheers,
    -Mikey

    Posted 13 years ago on Wednesday November 2, 2011 | Permalink
  4. You can use the gform_after_submission hook in version 1.6, or the gform_post_submission hook in anything prior to 1.6. That hook runs after the submission is validated, entry is created and notifications are sent. You can do whatever you want at that point.

    Here's a recent explanation from Alex about renaming the file after upload. You can use a similar process to watermark your images after upload.
    http://www.gravityhelp.com/forums/topic/append-a-prefix-to-file-uploads#post-39657

    Posted 13 years ago on Thursday November 3, 2011 | Permalink
  5. mmtrav
    Member

    Sorry but I'm really not a coder and can't quite figure out what that code is doing or how I need to change it to invoke the watermarking function. I'm quite helpless with that..

    add_action("gform_after_submission", "set_post_content", 10, 2);
    function set_post_content($entry, $form){
    
        //getting post
        $post = get_post($entry["post_id"]);
    
        //changing post content
        $post->post_content = "Blender Version:" . $entry[7] . "<br/> <img src='" . $entry[8] . "'> <br/> <br/> " . $entry[13] . " <br/> <img src='" . $entry[5] . "'>";
    
        //updating post
        wp_update_post($post);
    }

    I'm thinking that I need to change the part after changing post content. But I'm not sure how to write the code that will get the image file name, and run the function I need.

    should it be something like this?

    add_action("gform_after_submission", "watermark_post_image", 10, 2);
    function watermark_post_image($entry, $form){
    
    //Get post image
    $photopost_id = get_post($entry["post_id"]);
    
    // Here's where I get stuck -- what do I write to call the uploaded image for watermarking? 
    
    //Watermark post image
    MM_Execute_WM($file,'');

    My image field is ID 3 in the form. I am really stuck at this point.. please help me out?

    Posted 13 years ago on Thursday November 3, 2011 | Permalink
  6. Mikey, can you post a link to your form? With your form fields, I can give you a better code example.

    Generally though, the full URI to the images is in $entry[8] and $entry[5] in the 'blender' code. I'm not sure if your function needs a URI or a path to work.

    Posted 13 years ago on Friday November 4, 2011 | Permalink
  7. mmtrav
    Member

    Hi Chris,

    Yes, definitely. I've posted an example form here:

    http://photography.crowdsourced.travel/gravity-edit/

    The instruction for the watermark function is here:
    http://www.wp-watermark.com/installation

    It asks me to put in the function into the Wordpress media.php file located at /wordpress/wp-admin/includes/media.php.

    This makes the watermark work automatically on standard uploaded images via wordpress editor, but images sent via the gravity form do not get uploaded the same way.

    I hope that's all the information needed to make this work? Thanks for your help.

    Posted 13 years ago on Friday November 4, 2011 | Permalink
  8. mmtrav
    Member

    in short, I'm not sure if a path or a file name is required... I'll just check what the $file variable is calling..

    Okay I've checked -- it's definitely a path, not a URL.

    Posted 13 years ago on Friday November 4, 2011 | Permalink
  9. mmtrav
    Member

    Sorry to bump this guys, but am hoping to get support from you on this one as I still need the images to be watermarked upon upload and publication by the gravity form.

    Help appreciated..

    Posted 13 years ago on Saturday November 12, 2011 | Permalink
  10. Mikey, I made the mistake of continuing this topic in the pre-purchase forum. Would you please open a new topic with where you're at right now, including links to relevant pages (even this topic) in the regular support forums? We'll be happy to take a look at it there. Thank you.

    We try not to do forum support in the pre-purchase forum.

    Posted 13 years ago on Saturday November 12, 2011 | Permalink
  11. mmtrav
    Member

    actually, scratch that, I don't want to actually watermark my original images, I want to watermark the published images, which has to do with the theme I'm using, not gravity forms.

    Posted 13 years ago on Saturday November 12, 2011 | Permalink
  12. OK, that's a whole different animal. Should I consider this topic closed then?

    I know NextGen Gallery will do that, and there are also plugins at WordPress.org specifically for watermarking only:
    http://wordpress.org/extend/plugins/search.php?q=watermark&sort=

    Posted 13 years ago on Saturday November 12, 2011 | Permalink