Custom Metabox Plugin – Image Upload
-
Hello
I’ve created my own plugin which adds custom meta boxes to my posts.
In here, I’ve got a custom text field which holds the URL of an image selected in my Media Library.<section class="metabox"> <label for="image-preview"><?php _e('Preview')?></label> <input type="text" name="image-preview" id="image-preview" value="<?php if(isset($storedMeta['image-preview'])) echo $storedMeta['image-preview'][0]; ?>" /> <input type="button" id="image-preview-button" class="button" value="<?php _e('Choose or Upload an Image')?>" /> </section>
To display it, I use
get_post_meta($_GET['id'], 'image-preview', true);
, which does work. However, I would also like to use the metadata for that image, rather than have to add more custom fields to add the functionality I desire.Is there a better method to attach an image from the Media Library?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Custom Metabox Plugin – Image Upload’ is closed to new replies.