dozent_image_upload_field( string $input_name = 'image_id', null $current_image_id = null, bool $echo = true )
Generate an image upload field
Description
This function print an image upload field to upload instantly from the WordPress media manager.
See also
Parameters
- $input_name
-
(string) (Optional)
Default value: 'image_id'
- $current_image_id
-
(null) (Optional)
Default value: null
- $echo
-
(bool) (Optional)
Default value: true
Return
(string) $html HTML Putput
Source
File: includes/form-functions.php
function dozent_image_upload_field( $input_name = 'image_id', $current_image_id = null, $echo = true ){ if ( ! $input_name ){ $input_name = 'image_id'; } ob_start(); ?> <div class="dozent-image-field-wrap"> <a href="javascript:;" class="dozent-image-upload-toggle-btn"> <?php $img_src = dozent_placeholder_img_src(); if ( $current_image_id ) { $img_src = wp_get_attachment_image_url( $current_image_id, 'thumbnail' ); } ?> <img src="<?php echo $img_src; ?>" alt="" class="dozent-img-thumbnail" /> </a> <input type="hidden" name="<?php echo $input_name; ?>" class="image-input" value="<?php echo $current_image_id; ?>"> <div class="field-actions-wrap" style="display: none;"> <button type="button" class="dozent-btn dozent-btn-primary dozent-image-field-upload-btn"><i class="dicon-pencil"></i></button> <button type="button" class="dozent-btn dozent-btn-danger dozent-image-field-clear-btn"><i class="dicon-trash-line"></i></button> </div> </div> <?php $html = apply_filters( 'dozent_image_upload_field', ob_get_clean(), $input_name, $current_image_id ); if ( $echo ){ echo $html; } return $html; }
Changelog
Version | Description |
---|---|
DozentLMS 1.0.0 | Introduced. |