Forum: Ruby on Rails svg image link

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
jack (Guest)
on 2006-03-27 23:35
the link_to command is really nice, especially with confirm built in -
wondering if there is a way to use it with SVG images since SVG doesn't
seem to work with image_tag


I can display svg images (in Firefox) with the following code:

<embed width=32 height=32 src="/images/quit.svg"
type="image/svg+xml"></embed>

"normal" link_to code:

<%= link_to(image_tag("quit.png"),:controller=>"project",
:action=>"quit", 	:confirm=>"Existing Project Changes Might Get Lost -
Are You Sure?") %>

I can use straight html code with href calling .../project/quit but then
miss the nice confirm method
Pazu (Guest)
on 2006-03-28 00:03
(Received via mailing list)
jack <ngalaxy34@...> writes:

>
> the link_to command is really nice, especially with confirm built in -
> wondering if there is a way to use it with SVG images since SVG doesn't
> seem to work with image_tag
>
> I can display svg images (in Firefox) with the following code:
>
> <embed width=32 height=32 src="/images/quit.svg"
> type="image/svg+xml"></embed>

Try this:

<%=link_to "<embed width='32' height='32' src='<%=url_for
'quit.svg'%>'></embed>", :controller => 'project', :action => 'quit',
:confirm
=> "Existing Project Changes Might Get Lost -- Are You Sure?"%>

I haven't test this, but it should work. With that many nested quotes
you might
be better off escaping some of them.

-- Pazu
jack (Guest)
on 2006-03-29 10:11
thks for suggestion, I couldn't use the url_for , it gave me an
interminate string error but replacing it with the call to the /image
directory, the svg image shows up but no hyperlink:

<%= link_to "<embed width=32 height=32 src='/images/quit.svg'>
</embed>",
:controller=>'program', :action=>'quit', :confirm=>'Existing Project
Changes
Might Get Lost  Are You Sure?' %>

even if I wrap the link_to with parentheses like a regular link_to, it
still doesn't give the hyperlink  hmmm, I don't understand, any ideas?
jack


Pazu wrote:
> jack <ngalaxy34@...> writes:
>
>>
>> the link_to command is really nice, especially with confirm built in -
>> wondering if there is a way to use it with SVG images since SVG doesn't
>> seem to work with image_tag
>>
>> I can display svg images (in Firefox) with the following code:
>>
>> <embed width=32 height=32 src="/images/quit.svg"
>> type="image/svg+xml"></embed>
>
> Try this:
>
> <%=link_to "<embed width='32' height='32' src='<%=url_for
> 'quit.svg'%>'></embed>", :controller => 'project', :action => 'quit',
> :confirm
> => "Existing Project Changes Might Get Lost -- Are You Sure?"%>
>
> I haven't test this, but it should work. With that many nested quotes
> you might
> be better off escaping some of them.
>
> -- Pazu
This topic is locked and can not be replied to.