简体   繁体   中英

Mercury Editor save images

I used Mercury Editor for my Rails 3 website, but i have a litte problem with the uploaded images. I have a image tag with data-mercury="image":

<img id="page_image" data-mercury="image" >

Then I set Mercury to send the data via a form to my controller. What I want to do is to store the image's url in the database. How do I get the data sent by Mercury Editor ?

Normally when I have a div with data-mercury="full", I get the content in my controller like that:

params[:content][:page_content][:value]

Thanks for your help.

as I check the mercury demo , it saved the pictures url. So ,probably you can parse the content and capture the image url by using regular expression. Maybe you can use nokogiri as well to parse the html.

Rails Cast Source

Official Mercury docmentation

I resoved the problem with the following code:

#body

<img id="mercury_image" data-mercury="image" src="">
<div id="article_image" data-mercury="full"></div>

#jQuery

$(function() {
    $('#article_image').hide() ;
    $("#mercury_image").load(function(){ 
        $('#article_image').html($('#mercury_image').attr('src'));
    });
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM