PerfectlyNormal / tinymce-rails-imageupload

Image upload plugin for TinyMCE and Rails with the asset pipeline
MIT License
148 stars 153 forks source link

Thumbnails broken due to relative paths #56

Closed mkis- closed 10 years ago

mkis- commented 10 years ago

I'm using your gem in a Rails project that uses Active Admin. It provides forms for creating/editing models, at preset routes.

When creating a new model, the form is located at:

/admin/model_name/new

When editing a model, it is located at:

/admin/model_name/model_id/edit

Since the forms are at a different depth, images I uploaded while creating the model don't show up when editing it, as their relative paths point to the wrong location. This only affects the editor and said images have the correct paths otherwise.

PerfectlyNormal commented 10 years ago

Hi.

The plugin inserts an <img> tag using var imgstr = "<img src='" + json["image"]["url"] + "'";, so you might want to make sure your controller responds with an absolute URL, and not a relative. For example using the _url helpers in Rails, and not _path.

I've also configured my TinyMCE instances to translate relative URLs to absolute when saving (relative_urls: false in TinyMCE3), which might also help.

mkis- commented 10 years ago

I see. Thanks for the info.