ankurm
Forum Replies Created
-
Hi Chris,
Your functions worked perfectly but we can’t get $attachment_id of the images if they are inserted into the post.
I found a way through which I integrated your plugin to the gallery feature. Maybe you could add this functionality to your plugin.What I did was-
I observed that by using the gallery shortcode, I could get the attatchment_id of all the images. eg : [gallery ids="6500,6501"]
where 6500 and 6501 are the attachment ids of the images whose custom fields(that I created which your plugin) I wanted.So I decided to modify the gallery shortcode itself.
This is what i wrote in my function.php file
/* Editing shortcode for Gallery */ remove_shortcode('gallery', 'gallery_shortcode'); add_shortcode('gallery', 'gallery_shortcode_fancybox'); function gallery_shortcode_fancybox($attr) { ..... copy all the code from wp-includes/media.php which is inside the function gallery_shortcode() ..... }
After adding this to my functions.php, I was able to create my custom gallery shortcode without modifying the core files.
In between the function, where I needed to fetch the custom fields, I added this.
/* MY CUSTOM EDITS */ $work_status = strtolower(thisismyurl_get_custom_media_field( $id, 'my_unique_id' )); $output .= "<{$itemtag} class='gallery-item ".$work_status."'>"; $output .= "<{$icontag} class='gallery-icon'>".$link."</{$icontag}>"; /* MY CUSTOM EDITS Ends here*/
I was able to attach a class which I required.
Hope this helps you integrate your plugin with the gallery feature of the wordpress.
Thanks,
AnkurHi Chris!
I am using the latest version of wordpress (3.5.1).I was able to add the custom fields to the image and was also able to fetch the data but only if I set the image as a featured image.
My question is how can I fetch the custom field of the image which I insert into the post(not setting it as the featured image). Similarly what if i insert a few images as a gallery. How can I fetch their custom field data.
Thanks!
Ankur