Skip to content

Instantly share code, notes, and snippets.

@waiting-for-dev
Created August 20, 2013 09:14
Show Gist options
  • Save waiting-for-dev/6279143 to your computer and use it in GitHub Desktop.
Save waiting-for-dev/6279143 to your computer and use it in GitHub Desktop.
Replace RefineryCMS behaviour to add external images in the WYSIWYG editor. Remember to add it in 'initializers/refinery/core.rb' through the 'config/register_javascript' option
$(document).ready ->
$('.wym_tools_image a').click (e)->
e.stopImmediatePropagation()
e.preventDefault()
id = $('.wym_iframe').find('iframe:visible').attr('id').slice(-1)
url = prompt('Insert external image link')
img = new Image()
img.src = url
alt = prompt('Insert alternative text for the image')
wym = jQuery.wymeditors(id)
wym.insert('<img src="'+img.src+'" alt="'+alt+'" width="" height="" />')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment