WP Media Library Question

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
KatieMcW
New php-forum User
New php-forum User
Posts: 2
Joined: Tue May 22, 2018 9:42 am

Tue May 29, 2018 6:20 am

Hi

I have created a page called "settings.php" and I have added in the Media Library code which
seems to be working.

However, my code to save the url or the id isn't working.

If someone could help me out - much appreciated.

contents of my settings.php:

Code: Select all

<?php

function munic_tender_options() 
{
?>
    <div class="wrap">
        <h2>Settings</h2>
        <br/>

       <form method="post" action="options.php">
        <?php wp_nonce_field("update-options") ?>

        <div class="div-table-admin-plugin-sub-page">
	<div class="div-table-admin-plugin-sub-page-row">
	    <div class="div-table-admin-plugin-sub-page-hdg-col">
	    Logo:
	    </div>
	    <div class="div-table-admin-plugin-sub-page-reg-col">
     	    <?php wp_enqueue_media(); ?>
	    <img id="image-preview" src="http://townofbauline.ca/wp-content/plugins/bauline-tenders/img/town-logo.png" width="164" height="87" style="max-height: 87px; width: 164px;">
	    <input id="upload_image_button" type="button" class="button" value="<?php _e( 'Upload image' ); ?>" />
	    <input type="text" name="image_attachment_id" id="image_attachment_id" value="">

	    <br/><br/>
	    <input type="text" name="tlogo" size="45" maxlength="60" value="<?php echo get_option('image_attachment_id'); ?>" />
	    </div>
	</div>
        </div>

       <br/><br/>
       <input type="submit" name="Submit" value="Save Options" class="fbutton" />
       <input type="hidden" name="action" value="update" />
       <input type="hidden" name="page_options" value="tlogo" />
       </form>
       </div>
       <br class="clear">
      </div>

<?php
}
?>



contents of my functions file:

Code: Select all

<?php
function my_media_lib_uploader_enqueue() 
{
    wp_enqueue_media();
    wp_register_script ("js/media-lib-uploader-js", plugins_url("js/media-lib-uploader.js" , __FILE__ ), array("jquery") );
    wp_enqueue_script ("js/media-lib-uploader-js");
}
add_action ("admin_enqueue_scripts", "my_media_lib_uploader_enqueue");
?>

Post Reply