Browse Source

add manual photo URL field

pull/55/head
Aaron Parecki 8 years ago
parent
commit
9c3ef26741
  1. 16
      views/new-post.php

16
views/new-post.php

@ -27,6 +27,7 @@
<div class="form-group"> <div class="form-group">
<label for="note_photo"><code>photo</code></label> <label for="note_photo"><code>photo</code></label>
<input type="file" name="note_photo" id="note_photo" accept="image/*"> <input type="file" name="note_photo" id="note_photo" accept="image/*">
<a href="javascript:switchToManualPhotoURL();" id="note_manual_photo">enter photo url</a>
<br> <br>
<div id="photo_preview_container" class="hidden"> <div id="photo_preview_container" class="hidden">
<img src="" id="photo_preview" style="max-width: 300px; max-height: 300px;"> <img src="" id="photo_preview" style="max-width: 300px; max-height: 300px;">
@ -185,6 +186,17 @@ function replacePhotoWithPhotoURL(url) {
$("#note_photo").remove(); $("#note_photo").remove();
$("#photo_preview").attr("src", url); $("#photo_preview").attr("src", url);
$("#photo_preview_container").removeClass("hidden"); $("#photo_preview_container").removeClass("hidden");
$("#note_manual_photo").addClass("hidden");
}
function switchToManualPhotoURL() {
$("#note_photo").after('<input type="url" name="note_photo_url" id="note_photo_url" value="" class="form-control">');
$("#note_photo").remove();
$("#note_photo_url").change(function(){
$("#photo_preview").attr("src", $(this).val());
$("#photo_preview_container").removeClass("hidden");
});
$("#note_manual_photo").addClass("hidden");
} }
$(function(){ $(function(){
@ -193,7 +205,7 @@ $(function(){
var hasMediaEndpoint = <?= $this->media_endpoint ? 'true' : 'false' ?>; var hasMediaEndpoint = <?= $this->media_endpoint ? 'true' : 'false' ?>;
$("#note_content, #note_category, #note_in_reply_to, #note_slug").on('keyup change', function(e){
$("#note_content, #note_category, #note_in_reply_to, #note_slug, #note_photo_url").on('keyup change', function(e){
saveNoteState(); saveNoteState();
}) })
@ -233,8 +245,10 @@ $(function(){
}); });
$("#remove_photo").on("click", function(){ $("#remove_photo").on("click", function(){
$("#note_photo").val(""); $("#note_photo").val("");
$("#note_photo_url").val("");
$("#photo_preview").attr("src", "" ); $("#photo_preview").attr("src", "" );
$("#photo_preview_container").addClass("hidden"); $("#photo_preview_container").addClass("hidden");
saveNoteState();
}); });
$("#note_content").on('change keyup', function(e){ $("#note_content").on('change keyup', function(e){

Loading…
Cancel
Save