mardi 27 janvier 2015

WPAlchemy: Uploader with preview (like Featured image)


I am using WPAlchemy to generated custom meta boxes in the WP backend.


I was wondering when using the Media uploader if there’s a way to show the uploaded image in the meta box (like in the built-in Featured image metabox). By default only the link is entered in the input.


Here’s the code for the upload input:



<?php global $wpalchemy_media_access; ?>
<div class="my_meta_control">

<label>Uploader</label>
<?php $mb->the_field('download_url'); ?>
<?php $wpalchemy_media_access->setGroupName('img-n'. $mb->get_the_index())->setInsertButtonLabel('Insert'); ?>

<p>
<?php echo $wpalchemy_media_access->getField(array('name' => $mb->get_the_name(), 'value' => $mb->get_the_value())); ?>
<?php echo $wpalchemy_media_access->getButton(); ?>
</p>

</div>




Aucun commentaire:

Enregistrer un commentaire