Created
February 25, 2013 17:46
-
-
Save jbroadway/5031702 to your computer and use it in GitHub Desktop.
Image chooser with preview in form in Elefant
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
<!-- apps/demo/views/images.html --> | |
{! filemanager/util/browser !} | |
<form method="post" id="{{_form}}"> | |
<p> | |
<input type="submit" id="browse" value="{"Choose an image"}" /> | |
<input type="hidden" name="image" id="image" value="{{image|quotes}}" /> | |
</p> | |
<p> | |
{"Preview"}:<br /> | |
<img src="/apps/admin/css/admin/spacer.png" id="preview" /> | |
</p> | |
<p><input type="submit" value="{"Submit"}" /></p> | |
</form> | |
<style> | |
#preview { | |
width: 150px; | |
height: 90px; | |
border: 1px solid #ccc; | |
} | |
</style> | |
<script> | |
$(function () { | |
$('#browse').click (function () { | |
$.filebrowser ({ | |
thumbs: true, | |
title: '{"Choose an image"}', | |
set_value: '#image', | |
callback: function (file) { | |
$('#preview').attr ('src', file); | |
} | |
}); | |
return false; | |
}); | |
}); | |
</script> |
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
<?php // apps/demo/handlers/images.php | |
$this->require_admin (); | |
$page->layout = 'admin'; | |
$page->title = __ ('Image Chooser Example'); | |
$form = new Form ('post', $this); | |
echo $form->handle (function ($form) use ($page) { | |
$page->title = __ ('Your Image:'); | |
printf ('<p><img src="%s" /></p>', $_POST['image']); | |
}); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment