Created
May 17, 2012 06:49
-
-
Save imjjss/2717067 to your computer and use it in GitHub Desktop.
change banner img using media gallery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<a href="media-upload.php?type=image&TB_iframe=true" class="thickbox" title="Select A Banner Image From Gallery" onclick="return false;" class="thickbox"> | |
<img id="banner_image" src="<?php echo(htmlentities($banner_image)); ?>" width="450" height="25" /> | |
</a> | |
<input type="hidden" id="banner_image_input" name="banner_image" value="<?php echo(htmlentities($banner_image)); ?>" /> | |
<?php | |
/* | |
strip out everything but the image source and updates the form. First, the function eliminates all of the text returned except the image source. It then updates the banner image and the hidden input value that I am using in my form: | |
*/ | |
function send_to_editor(html) { | |
var source = html.match(/src=\".*\" alt/); | |
source = source[0].replace(/^src=\"/, "").replace(/" alt$/, ""); | |
$("#banner_image").attr('src', source); | |
$('#banner_image_input").attr('value', source); | |
tb_remove(); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is not as smart as re-attach plugin