Commit fc388ee0 authored by jan.koester's avatar jan.koester
Browse files

test

parent 25b417d4
Loading
Loading
Loading
Loading
+2 −2
Changes for data/template/default/editor.html: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -2749,7 +2749,7 @@
                const w = rw ? parseInt(rw.value, 10) || 0 : 0;
                const h = rh ? parseInt(rh.value, 10) || 0 : 0;
                let url = origUrl;
                if (w > 0 && h > 0) url += '?' + w + 'x' + h;
                if (w > 0 && h > 0) url += '?w=' + w + '&h=' + h;
                srcEl.value = url;
                srcEl.dispatchEvent(new Event('input', { bubbles: true }));
            }
@@ -2803,7 +2803,7 @@
                        const w = rwEl ? parseInt(rwEl.value, 10) || 0 : 0;
                        const h = rhEl ? parseInt(rhEl.value, 10) || 0 : 0;
                        let url = PREFIX + '/media/getimage/' + mid + '.' + ext;
                        if (w > 0 && h > 0) url += '?' + w + 'x' + h;
                        if (w > 0 && h > 0) url += '?w=' + w + '&h=' + h;
                        srcEl.value = url;
                    }
                    await triggerPreviewCreation();
+11 −14
Changes for plugins/media/media.cpp: 11 added lines, 14 removed lines.
Original line number Diff line number Diff line
@@ -576,8 +576,8 @@ namespace blogi {
                if( mlen <= plen )
                    return true;

                // Extract media ID, extension and optional WxH from URL
                // Format: <uuid>.<ext>?<W>x<H>
                // Extract media ID and extension from URL path
                // Format: <uuid>.<ext>  with query params ?w=<W>&h=<H>
                std::string mediaId = req.getRequestURL().substr(plen);
                std::string fmt;
                int reqWidth = 0, reqHeight = 0;
@@ -586,17 +586,14 @@ namespace blogi {
                    fmt = mediaId.substr(dotPos + 1);
                    mediaId = mediaId.substr(0, dotPos);
                }
                // Separate query params (?WxH) from fmt
                size_t qmPos = fmt.find('?');
                if(qmPos != std::string::npos){
                    std::string qs = fmt.substr(qmPos + 1);
                    fmt = fmt.substr(0, qmPos);
                    size_t xPos = qs.find('x');
                    if(xPos != std::string::npos){
                        try {
                            reqWidth = std::stoi(qs.substr(0, xPos));
                            reqHeight = std::stoi(qs.substr(xPos + 1));
                        } catch(...) {}

                // Parse w= and h= from query string via HttpForm
                {
                    libhttppp::HttpForm qform;
                    qform.parse(req);
                    for(const auto &qp : qform.urlData()){
                        if(qp.key == "w"){ try { reqWidth = std::stoi(qp.value); } catch(...) {} }
                        else if(qp.key == "h"){ try { reqHeight = std::stoi(qp.value); } catch(...) {} }
                    }
                }

@@ -875,7 +872,7 @@ namespace blogi {
                    _mdb[tid]->get_preview(mediaId, opts, &ct);
                    _addAllowedSize(tid, width, height);
                    std::string url = Args->config->buildurl("media/getimage/") + mi.id + "." + ext
                                     + "?" + std::to_string(width) + "x" + std::to_string(height);
                                     + "?w=" + std::to_string(width) + "&h=" + std::to_string(height);
                    json_object_object_add(response, "status", json_object_new_string("success"));
                    json_object_object_add(response, "url", json_object_new_string(url.c_str()));
                    json_object_object_add(response, "width", json_object_new_int(width));