I once created a job board with Formidable Forms Pro, where the unique Job-Code is a combination of post-ID and another field that the client adds and this Job Code is automatically added to the form.
You can see it in action here (click on the Apply button).
]]>There are a few ways you could approach this:
– pure javascript solution
– inserting a form for each image and having that post the data to a specific page
– add a link around each image passing in the query of the image alt text
I think the simplest will be the 3rd option. Add an anchor tag around each image as follows:
<a href="path_to_contact-page-product?img_alt=<?php get_image_tag( $id, $alt, $title, $align, $size ); ?>"><img></a>
Then on the contact-page-product you will have access to the alt text via the $_GET array ($_GET[‘img_alt’]) and can place that into the field as required (I assume as a hidden input).
I hope that makes sense,
Joey
Thanks for helping me, when i now click on the image it does send me to the contact form page, but it doesnt get the alt text.
The code is use for this image slider is:
<div class="wpsisac-slick-carousal-1 wpsisac-slick-carousal design-6 variablewidthv">
<?php
for($i=0; $i<count($att_id_arr); $i++)
{
$img_url = wp_get_attachment_url( $att_id_arr[$i] );
?>
<div class="slick-image-slide">
<a href="/offerte-aanvraag-product?img_alt=<?php get_image_tag( $id, $alt, $title, $align, $size ); ?>"><img width="275" height="180" src="<?=$img_url?>" class="attachment-medium size-medium wp-post-image c-imgae" alt="<?php echo get_post_meta($att_id_arr[$i], '_wp_attachment_image_alt', true);?>"/></a>
</div>
<?
}
?>
</div>
when i click on the image it does send me to the page, but it doesn’t get the image alt text. The link looks like this when i click on it:
https://simbeton.nl/offerte-aanvraag-product/?img_alt=
Also i dont know how to insert the PHP code
$_GET array ($_GET[‘img_alt’])
into the W7 form contact page, i read something about creating a shortcode for this PHP code and insert it that way, but i am also not sure how.
Thanks for helping, and sorry for my bad englisch.
Greetings,
Gerwin
Shortcodes are not processed in CF7, you need to hook a filter and run content through do_shortcode(). What you think is PHP, the $_GET array ($_GET[‘img_alt’]), is not all PHP, only $_GET['img_alt']
is what you want. Also pay attention to quote styles when copy/pasting. Only straight style works in code, the “curly quotes” used by this forum will cause syntax errors.
Your shortcode will need to output the entire input field because shortcodes in HTML tags or CF7 fields are ignored. You then need to do the entire thing again, only differently with the email template, this time the data comes from $_POST[‘field-name-here’].
Information on making shortcodes is in the Shortcode API. Information on hooking filters is part of the Plugin Handbook.
]]>It turns out get_image_tag() doesn’t do what Joey thought it did, it will not work for your needs. Instead, replace that with echo esc_url( get_post_meta( $att_id_arr[$i], '_wp_attachment_image_alt', true ));
Keep the <?php ?> tags.
Once your links include the alt attribute text correctly, we need to figure out how to add it to a CF7 field. I had thought there would be a filter where shortcodes could be processed, but that’s not the case, so shortcodes are out. It appears to be a simple thing, you just need to coordinate the tag name with the “img_alt” URL parameter. See the CF7 Docs.
]]>