Fix cannot del&red img #185

This commit is contained in:
cutls 2019-12-14 10:12:18 +09:00
parent adf37f6513
commit c318803ecd

View File

@ -420,20 +420,27 @@ function redraft(id, acct_id) {
$('select').formSelect() $('select').formSelect()
mdCheck() mdCheck()
var medias = $('[toot-id=' + id + ']').attr('data-medias') var medias = $('[toot-id=' + id + ']').attr('data-medias')
var mediack = json.media_attachments[0]
//メディアがあれば
var media_ids = []
if (mediack) {
for (var i = 0; i <= 4; i++) {
if (json.media_attachments[i]) {
media_ids.push(json.media_attachments[i].id)
$('#preview').append(
'<img src="' +
json.media_attachments[i].preview_url +
'" style="width:50px; max-height:100px;">'
)
} else {
break
}
}
}
var vismode = $('[toot-id=' + id + '] .vis-data').attr('data-vis') var vismode = $('[toot-id=' + id + '] .vis-data').attr('data-vis')
vis(vismode) vis(vismode)
var medias = media_ids.join(',');
$('#media').val(medias) $('#media').val(medias)
var ct = 0
if (medias && medias != 'null') {
ct = medias.split(',').length
}
$('[toot-id=' + id + '] img.toot-img').each(function(i, elem) {
if (i < ct) {
var url = $(elem).attr('src')
console.log('Play back image data:' + url)
$('#preview').append('<img src="' + url + '" style="width:50px; max-height:100px;">')
}
})
localStorage.setItem('nohide', true) localStorage.setItem('nohide', true)
show() show()
if (json.text) { if (json.text) {