Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // http://www.gravityhelp.com/forums/topic/make-an-image-a-link-in-post-template
- // change the 171 here to your actual form ID
- add_action('gform_pre_submission_filter_171', 'change_post_content_template');
- function change_post_content_template($form) {
- // if input_5 is submitted, i.e. has an image, then insert the HTML into the content template. Otherwise, just use {Details:2}
- // check the $_FILES global since it's an image upload
- if ((!isset($_FILES['input_5']['name']) || $_FILES['input_5']['name'] == null)) {
- $form['postContentTemplate'] = '{Details:2}';
- }
- else {
- // use a PHP heredoc to preserve line breaks
- $template = <<<EOT
- <a href='{Image:5:large:url}'>{Image:5:listing:right}</a>
- {Details:2}
- EOT;
- $form['postContentTemplate'] = $template;
- }
- // return the modified form object
- return $form;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement