Loading plugins/media/media.cpp +13 −2 Changes for plugins/media/media.cpp: 13 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -601,7 +601,7 @@ namespace blogi { << " reqWidth=" << reqWidth << " reqHeight=" << reqHeight << std::endl; // Validate against allowed preview sizes if(reqWidth > 0 && reqHeight > 0 && !_isSizeAllowed(reqWidth, reqHeight)){ if((reqWidth > 0 || reqHeight > 0) && !_isSizeAllowed(reqWidth, reqHeight)){ libhttppp::HttpResponse curres; curres.setState(HTTP403); curres.send(req, "", 0); Loading Loading @@ -752,7 +752,12 @@ namespace blogi { _storeStreamState(req, std::move(streamClient), sendSize, tid); libhttppp::HttpResponse curres; curres.setContentType(mi.content_type.c_str()); // Set content type based on requested format if(fmt == "webp") curres.setContentType("image/webp"); else if(fmt == "png") curres.setContentType("image/png"); else if(fmt == "jpeg" || fmt == "jpg") curres.setContentType("image/jpeg"); else if(fmt == "avif") curres.setContentType("image/avif"); else curres.setContentType(mi.content_type.c_str()); curres.setHeaderData("Accept-Ranges")->push_back("bytes"); curres.setHeaderData("Cache-Control")->push_back("public, max-age=86400"); Loading Loading @@ -1139,7 +1144,13 @@ namespace blogi { if(w == 0 && h == 0) return true; std::lock_guard<std::mutex> lock(_sizesMutex); for(const auto &s : _allowedSizes){ if(w > 0 && h > 0){ if(s.w == w && s.h == h) return true; } else if(w > 0){ if(s.w == w) return true; } else if(h > 0){ if(s.h == h) return true; } } return false; } Loading plugins/survey/survey.cpp +8 −1 Changes for plugins/survey/survey.cpp: 8 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -2745,6 +2745,12 @@ namespace blogi { << "if(aid&&Array.isArray(r))r=r.slice(1);cb(null,r);}catch(e){cb(e);}}};" << "xhr.send(JSON.stringify(cmds));}" << "" << "var _sizesRegistered=false;" << "function ensureSizesRegistered(mediaId){" << "if(_sizesRegistered)return;_sizesRegistered=true;" << "apiCall([{command:'media_create_preview',media_id:mediaId,width:100,height:100}],function(){});" << "apiCall([{command:'media_create_preview',media_id:mediaId,width:64,height:64}],function(){});}" << "" << "function openMediaPicker(targetInput){" << "var old=document.getElementById('se-media-modal');if(old)old.remove();" << "var ov=document.createElement('div');ov.id='se-media-modal';" Loading Loading @@ -2781,6 +2787,7 @@ namespace blogi { << "if(!ml||ml.length===0){contentEl.textContent='Leer';return;}" << "var h='<div style=\"display:grid;grid-template-columns:repeat(auto-fill,minmax(100px,1fr));gap:8px;\">';" << "for(var i=0;i<ml.length;i++){var m=ml[i];" << "if(i===0)ensureSizesRegistered(m.id);" << "var thumb=m.url+'?w=100&h=100';" << "h+='<div class=\"se-mb-item\" data-url=\"'+esc(m.url)+'\" style=\"cursor:pointer;border:2px solid transparent;border-radius:8px;padding:4px;background:#3a3e42;text-align:center;\">';" << "if(m.kind==='image')h+='<img src=\"'+esc(thumb)+'\" loading=\"lazy\" style=\"width:100%;height:70px;object-fit:cover;border-radius:4px;\"/>';" Loading @@ -2790,7 +2797,7 @@ namespace blogi { << "contentEl.onclick=function(ev){" << "var it=ev.target.closest('.se-mb-item');if(!it)return;" << "var murl=it.getAttribute('data-url');" << "targetInput.value=murl+'?w=64';" << "targetInput.value=murl+'?w=64&h=64';" << "ov.remove();};});}" << "" << "render();" Loading Loading
plugins/media/media.cpp +13 −2 Changes for plugins/media/media.cpp: 13 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -601,7 +601,7 @@ namespace blogi { << " reqWidth=" << reqWidth << " reqHeight=" << reqHeight << std::endl; // Validate against allowed preview sizes if(reqWidth > 0 && reqHeight > 0 && !_isSizeAllowed(reqWidth, reqHeight)){ if((reqWidth > 0 || reqHeight > 0) && !_isSizeAllowed(reqWidth, reqHeight)){ libhttppp::HttpResponse curres; curres.setState(HTTP403); curres.send(req, "", 0); Loading Loading @@ -752,7 +752,12 @@ namespace blogi { _storeStreamState(req, std::move(streamClient), sendSize, tid); libhttppp::HttpResponse curres; curres.setContentType(mi.content_type.c_str()); // Set content type based on requested format if(fmt == "webp") curres.setContentType("image/webp"); else if(fmt == "png") curres.setContentType("image/png"); else if(fmt == "jpeg" || fmt == "jpg") curres.setContentType("image/jpeg"); else if(fmt == "avif") curres.setContentType("image/avif"); else curres.setContentType(mi.content_type.c_str()); curres.setHeaderData("Accept-Ranges")->push_back("bytes"); curres.setHeaderData("Cache-Control")->push_back("public, max-age=86400"); Loading Loading @@ -1139,7 +1144,13 @@ namespace blogi { if(w == 0 && h == 0) return true; std::lock_guard<std::mutex> lock(_sizesMutex); for(const auto &s : _allowedSizes){ if(w > 0 && h > 0){ if(s.w == w && s.h == h) return true; } else if(w > 0){ if(s.w == w) return true; } else if(h > 0){ if(s.h == h) return true; } } return false; } Loading
plugins/survey/survey.cpp +8 −1 Changes for plugins/survey/survey.cpp: 8 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -2745,6 +2745,12 @@ namespace blogi { << "if(aid&&Array.isArray(r))r=r.slice(1);cb(null,r);}catch(e){cb(e);}}};" << "xhr.send(JSON.stringify(cmds));}" << "" << "var _sizesRegistered=false;" << "function ensureSizesRegistered(mediaId){" << "if(_sizesRegistered)return;_sizesRegistered=true;" << "apiCall([{command:'media_create_preview',media_id:mediaId,width:100,height:100}],function(){});" << "apiCall([{command:'media_create_preview',media_id:mediaId,width:64,height:64}],function(){});}" << "" << "function openMediaPicker(targetInput){" << "var old=document.getElementById('se-media-modal');if(old)old.remove();" << "var ov=document.createElement('div');ov.id='se-media-modal';" Loading Loading @@ -2781,6 +2787,7 @@ namespace blogi { << "if(!ml||ml.length===0){contentEl.textContent='Leer';return;}" << "var h='<div style=\"display:grid;grid-template-columns:repeat(auto-fill,minmax(100px,1fr));gap:8px;\">';" << "for(var i=0;i<ml.length;i++){var m=ml[i];" << "if(i===0)ensureSizesRegistered(m.id);" << "var thumb=m.url+'?w=100&h=100';" << "h+='<div class=\"se-mb-item\" data-url=\"'+esc(m.url)+'\" style=\"cursor:pointer;border:2px solid transparent;border-radius:8px;padding:4px;background:#3a3e42;text-align:center;\">';" << "if(m.kind==='image')h+='<img src=\"'+esc(thumb)+'\" loading=\"lazy\" style=\"width:100%;height:70px;object-fit:cover;border-radius:4px;\"/>';" Loading @@ -2790,7 +2797,7 @@ namespace blogi { << "contentEl.onclick=function(ev){" << "var it=ev.target.closest('.se-mb-item');if(!it)return;" << "var murl=it.getAttribute('data-url');" << "targetInput.value=murl+'?w=64';" << "targetInput.value=murl+'?w=64&h=64';" << "ov.remove();};});}" << "" << "render();" Loading