Change TinyMCE image upload relative URL - url

I'm using tinymce on Laravel, my upload path is /upload/img.jpg
but when I save my form to database, tinymce convert the URL to relative one to ../upload, how to change this relative URLĀ  from ../upload to /upload

I stumbled across this same issue today. You can solve this by setting the relative_urls configuration option to false when initializing your tinymce instance:
tinymce.init({
selector: "#targetElement",
[...]
relative_urls: false,
})
This was buried in the documentation at: https://www.tiny.cloud/docs/configure/url-handling/#relative_urls

TinyMCE has a variety of settings that impact how URLs are handled. The documentation site lists them all here:
https://www.tiny.cloud/docs/configure/url-handling/
I would look at how you have TinyMCE configured and determine which of these settings will get you the end result you desire.

Related

customized symfony 3 form template

I tried to create a customized theme form symfony_3 form.
path: app/Resources/views/form
And I set the form as current theme
$view['form']->setTheme($form, array('app/Resources/views/form'));?>
But that does not work and the system calls the default symfony form theme. How can I fix that?
you could try define the form theming globaly in your config.yml as explained in this doc or locally like this other doc:
Hope it helps

Reveal.js Sharable links to specific slide / Keep current slide on reload

Using Reveal.js, I can't find any documentation of this feature. I'm positive I've seen this somewhere. And I would sure like to be able to reload the page and not have to navigate through the entire deck every time.
Does it exist as a hidden feature? Does anyone know of a "plugin" or patch?
The trick is to set history: true in the configuraton at the end of the index.html page:
Reveal.initialize({
history: true,
...
The update from 2022 relevant for Reveal.JS 4.3.1:
Trick with history no longer works, use hash instead:
new Reveal({
plugins: [Markdown, Highlight],
hash: true,
}).initialize();
Link to the documentation

Rails tinymce gem and tinymce-rails-imageupload gem broken image on edit action

I have successfully setup the tinymce gem and the tinymce-rails-imageupload gem (using paperclip to handle image storing) and they are working well together however when I go to edit a page I get a broken image inside the tinymce editor. The server log shows the following error message:
ActionController::RoutingError (No route matches [GET] "/pages/system/images/files/000/000/002/original/test.jpg"):
The image renders fine inside the tinymce editor when I create a new page and upload it initially and also displays fine on the show action for the page but for some reason on the edit action it sticks the controller '/pages/' into the file path. The images actual location is:
system/images/files/000/000/002/original/test.jpg?1418950559
How do I set the route for the image so it works in the edit action for pages?
Alright, after getting some food I think I have identified the issue.
You stated that it works fine on the "Show" action (meaning the TinyMCE editor is not involved at that point) and it also works on the "Create" action (so the initial creation process works to include it in the TinyMCE) however it does not work in the Edit action.
I think you simply need to change one setting on the Javascript for TinyMCE to indicate that relative urls are being used. So undo what I told you previously, and then for the tinyMCE javascript:
$("[rel=tinymce]").tinymce({
theme: "modern",
...
relative_urls: false
...
As it turns out, it was required to set the relative_URLs setting on tinyMCE configuration to false.

Current URL in hyperlink for Joomla tpl file

i have the joomla TPL file, its has hyper link with
{$ROOT_HOST}/&liststyle=grid
i need to replace the {$ROOT_HOST} with the current URL and its full parameters to include the grid style tab # to the end of the current url. this is done in tpl file.
SO can any one tell me if there is a possibilty to include the #grid to the Current page url(parameter)
I tried {$CURRENT_URI} but didnt work still getting the main host url!.
please help :)
you should be using JURI like MasterAM stated http://docs.joomla.org/JURI/current

How to retrieve web site favicons?

I am using Ruby on Rails v3.0.9 and I would like to retrieve the favicon.ico image of each web site for which I set a link.
That is, if in my application I set the http://www.facebook.com/ URL I would like to retrieve the Facebook' icon and use\insert that in my web pages. Of course I would like to do that also for all other web sites.
How can I retrieve favicon.ico icons from web sites in an "automatic" way (with "automatic" I mean to search for a favicon in a web site and get the link to it - I think no because not all web sites have a favicon named exactly 'favicon.ico'. I would like to recognize that in an "automatic" way)?
P.S.: What I would like to make is something like Facebook makes when to add a link\URL in your Facebook page: it recognizes the related web site logo and then appends that to the link\URL.
http://getfavicon.appspot.com/ works great for fetching favicons. Just give it the url for the site and you'll get the favicon back:
http://g.etfv.co/http://www.google.com
Recently I have written some similar solution.
If we want find favicon url, that can be not only .ico file and can be not in the root, we should parse target site html.
In Ruby on Rails, I have used nokogiri gem for html parsing.
First we parse all meta tags where itemprop attribute contains image keyword. It is necessary in situations where target site used https://schema.org/WebPage template, that more modern technology than just link tag.
If we found it, we can use content attribute as favicon url. But we should check it for really URL existence, just to be sure.
If we can't found some meta tags, then we search for standard link tags, where rel attribute contains icon keyword. This is W3C standard situation (https://www.w3.org/2005/10/howto-favicon)
And some code of my solution:
require 'open-uri'
def site_icon_link site
icon_link = nil
url = nil
doc = Nokogiri::HTML(open(site))
metas = doc.css("meta[itemprop*=image]")
if metas.any?
url = metas.first.attributes['content'].value
else
links = doc.css("link[rel*=icon]")
if links.any?
url = links.first.attributes['href'].value
end
end
if url =~ URI::regexp
icon_link = url
elsif (site + url) =~ URI::regexp
icon_link = site + url
end
icon_link
end
The favicons are being found by two ways. First, there is a 'hardcoded', traditional name of `http://example.com/favicon.ico'.
Second, the HTML pages may define the favicon in their <head> sections, by <link rel="icon"...> and a few other. (You may want to read the Wikipedia article about favicon)
So, your automat may fetch the main page of given website, parse it and check whether there are proper <link> tags, and then, as a fallback, try the "hardcoded" favicon.ico name.
I think I missed your question ...
you want to grab a favicon from another site and make it yours?
if that's what you want, you can get directly from the home icon and save it in your public folder.
thus: www.facebook.com favicon: www.facebook.com/favicon.ico
take that image and save with the name favicon in your public folder
done it should be sufficient
if you want it dinamicaly you can use jquery, but if you want that static you can put a image tag pointing to: [root url of the website]/favicon.ico
like this: <%= image_tag "#{website.url}/favicon.ico" %>
With javascript (jQuery), like this: http://jsfiddle.net/aX8T4/
Can't you just use a regular img tag with the src attribute pointing to the favicon?
<img src="http://www.facebook.com/favicon.icon">
This assumes a browser recognizes a .ico file as an image. Helped methods would probably work with this too.
You can do it easily with pismo gem.
Quick example to get the url of Facebook's favicon:
Pismo::Document.new('http://www.facebook.com/').favicon
Here's my ruby method, that will strip the end off a URL, append the favicon, and produce an image tag.
def favicon_for(url)
matches = url.match(/[^:\/]\/(.*)/)
image_tag url.sub(matches[1], '') + '/favicon.ico', {width: '16px', height: '16px'}
end

Resources