How do I insert the URL of an uploaded image into a custom field?
Author | Posts |
---|---|
July 16, 2013 at 4:15 am 6005 | |
Hello, I am trying to have the user upload an image, then store the URL to the image in a custom field automatically. Is there a piece of code (hook) that I can use to do this? Thanks in advance! | |
July 16, 2013 at 6:44 pm 6029 | |
You can also simply get the url of attached images. http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src | |
July 16, 2013 at 7:31 pm 6033 | |
As @MDelcour already provided the function reference, you can use like this [php] | |
August 1, 2013 at 9:03 am 6550 | |
Sorry, I guess I should have elaborated. I am using the WP-front-end-pro form to upload an image that is attached to a custom field called Thumbnail.. works great, except it inserts the image ID number. What I wold like it to do is insert the url for the image instead. Where can I change this in the plug-in code? Simply replace the image ID with the image URL when someone uploads the image. | |
August 2, 2013 at 1:13 am 6576 | |
That ID is needed when editing the attachment, otherwise it’ll break. One thing you could do, save the attachment URL in another custom field. Put the custom field name in the [php] if ( $attach_id ) { add_action( ‘wpuf_add_post_after_insert’, ‘wpufe_copy_att_url’ ); | |
August 2, 2013 at 3:41 am 6581 | |
Worked Perfectly! Thank you! |