Loading editor/html/js/properties.js +5 −0 Original line number Diff line number Diff line Loading @@ -130,6 +130,11 @@ var PropertiesPanel = (function() { if (typeof MediaBrowser !== 'undefined') { MediaBrowser.open(function(mediaItem) { inp.value = mediaItem.id; // Also set src field from media URL (includes blog prefix) if (mediaItem.url) { var srcInput = form.querySelector('input[name="src"]'); if (srcInput) srcInput.value = mediaItem.url; } inp.dispatchEvent(new Event('change')); }); } Loading editor/src/webedit_api.cpp +46 −0 Original line number Diff line number Diff line Loading @@ -710,6 +710,52 @@ void webedit::Api::handleSetProperties(libhttppp::HttpRequest &curreq, json_object *respJson = json_object_new_object(); el->JsonApi(reqJson, respJson); // If properties contain media_id + real_width/real_height, register // the preview size with the blog so media/getimage allows it. json_object *propsObj = nullptr; if (json_object_object_get_ex(reqJson, "properties", &propsObj)) { json_object *midObj = nullptr, *rwObj = nullptr, *rhObj = nullptr; if (json_object_object_get_ex(propsObj, "media_id", &midObj) && json_object_object_get_ex(propsObj, "real_width", &rwObj)) { std::string mediaId = json_object_get_string(midObj); int rw = json_object_get_int(rwObj); int rh = 0; if (json_object_object_get_ex(propsObj, "real_height", &rhObj)) rh = json_object_get_int(rhObj); if (!mediaId.empty() && (rw > 0 || rh > 0)) { // Fire-and-forget: register preview size via first active connection std::string authid, blogUrl; { std::lock_guard<std::mutex> clk(_connSessionMtx); if (!_connSessions.empty()) { auto it = _connSessions.begin(); authid = it->second.authid; blogUrl = it->second.blogUrl; } } if (!authid.empty()) { try { json_object *apiArr = json_object_new_array(); json_object *authJ = json_object_new_object(); json_object_object_add(authJ, "authid", json_object_new_string(authid.c_str())); json_object_array_add(apiArr, authJ); json_object *cmd = json_object_new_object(); json_object_object_add(cmd, "command", json_object_new_string("media_create_preview")); json_object_object_add(cmd, "media_id", json_object_new_string(mediaId.c_str())); json_object_object_add(cmd, "width", json_object_new_int(rw)); json_object_object_add(cmd, "height", json_object_new_int(rh)); json_object_array_add(apiArr, cmd); json_object *apiResp = blogApiCall(blogUrl, apiArr); json_object_put(apiArr); if (apiResp) json_object_put(apiResp); } catch (...) { // Best effort — don't fail the property save } } } } } sendJson(curreq, respJson); json_object_put(reqJson); json_object_put(respJson); Loading editor/widgets/image/image.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -405,8 +405,8 @@ extern "C" { if (val) customCss = val; } // Auto-derive src from media_id when set if (!mediaId.empty()) { // Auto-derive src from media_id when not explicitly provided if (!mediaId.empty() && src.empty()) { src = "/media/getimage/" + mediaId + "." + mediaExt; } Loading editor/widgets/video/video.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -343,8 +343,8 @@ extern "C" { if (val) customCss = val; } // Auto-derive src from media_id when set if (!mediaId.empty()) { // Auto-derive src from media_id when not explicitly provided if (!mediaId.empty() && src.empty()) { src = "/media/getimage/" + mediaId + "." + mediaExt; } Loading Loading
editor/html/js/properties.js +5 −0 Original line number Diff line number Diff line Loading @@ -130,6 +130,11 @@ var PropertiesPanel = (function() { if (typeof MediaBrowser !== 'undefined') { MediaBrowser.open(function(mediaItem) { inp.value = mediaItem.id; // Also set src field from media URL (includes blog prefix) if (mediaItem.url) { var srcInput = form.querySelector('input[name="src"]'); if (srcInput) srcInput.value = mediaItem.url; } inp.dispatchEvent(new Event('change')); }); } Loading
editor/src/webedit_api.cpp +46 −0 Original line number Diff line number Diff line Loading @@ -710,6 +710,52 @@ void webedit::Api::handleSetProperties(libhttppp::HttpRequest &curreq, json_object *respJson = json_object_new_object(); el->JsonApi(reqJson, respJson); // If properties contain media_id + real_width/real_height, register // the preview size with the blog so media/getimage allows it. json_object *propsObj = nullptr; if (json_object_object_get_ex(reqJson, "properties", &propsObj)) { json_object *midObj = nullptr, *rwObj = nullptr, *rhObj = nullptr; if (json_object_object_get_ex(propsObj, "media_id", &midObj) && json_object_object_get_ex(propsObj, "real_width", &rwObj)) { std::string mediaId = json_object_get_string(midObj); int rw = json_object_get_int(rwObj); int rh = 0; if (json_object_object_get_ex(propsObj, "real_height", &rhObj)) rh = json_object_get_int(rhObj); if (!mediaId.empty() && (rw > 0 || rh > 0)) { // Fire-and-forget: register preview size via first active connection std::string authid, blogUrl; { std::lock_guard<std::mutex> clk(_connSessionMtx); if (!_connSessions.empty()) { auto it = _connSessions.begin(); authid = it->second.authid; blogUrl = it->second.blogUrl; } } if (!authid.empty()) { try { json_object *apiArr = json_object_new_array(); json_object *authJ = json_object_new_object(); json_object_object_add(authJ, "authid", json_object_new_string(authid.c_str())); json_object_array_add(apiArr, authJ); json_object *cmd = json_object_new_object(); json_object_object_add(cmd, "command", json_object_new_string("media_create_preview")); json_object_object_add(cmd, "media_id", json_object_new_string(mediaId.c_str())); json_object_object_add(cmd, "width", json_object_new_int(rw)); json_object_object_add(cmd, "height", json_object_new_int(rh)); json_object_array_add(apiArr, cmd); json_object *apiResp = blogApiCall(blogUrl, apiArr); json_object_put(apiArr); if (apiResp) json_object_put(apiResp); } catch (...) { // Best effort — don't fail the property save } } } } } sendJson(curreq, respJson); json_object_put(reqJson); json_object_put(respJson); Loading
editor/widgets/image/image.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -405,8 +405,8 @@ extern "C" { if (val) customCss = val; } // Auto-derive src from media_id when set if (!mediaId.empty()) { // Auto-derive src from media_id when not explicitly provided if (!mediaId.empty() && src.empty()) { src = "/media/getimage/" + mediaId + "." + mediaExt; } Loading
editor/widgets/video/video.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -343,8 +343,8 @@ extern "C" { if (val) customCss = val; } // Auto-derive src from media_id when set if (!mediaId.empty()) { // Auto-derive src from media_id when not explicitly provided if (!mediaId.empty() && src.empty()) { src = "/media/getimage/" + mediaId + "." + mediaExt; } Loading