Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-04-26 13:10:28

laptophobo
Member
Registered: 2010-03-01
Posts: 216
Website

Inserting and linking an image

Hello,

I’m having a heck of a time inserting an image—an image that will link to a URL (preferably with target=blank ability).

Firstly, I’ve been using this tag in my articles: <txp:image id=“5” />
This works fine for a simple image. I need it for it to link.

But for a linking image, TXP says to do something like this: !images/imagename.jpg!:http://www.adobe.com/acrobat/

The problem is that this requires that I FTP the image into my website, bypassing the Import Image function with TXP. Also, there appears to be no option to open a new browser page (target=blank).

So, is there a way to link an image, an image within my TXP image base? (preferably having the option to open a blank page)?

Thanks much!

EDIT Stef: code formatting

Last edited by Bloke (2010-04-26 13:38:31)


Living the Location-Independent Life: www.NuNomad.com

Offline

#2 2010-04-26 13:31:13

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 638
Website

Re: Inserting and linking an image

Sorry, I just do not understand your problem.

Do you want to use ‘Textile’ for linking an image inside your article body/excerpt like this !imageurl!:http:// ?
If so: then you need a plugin to get only the image url without the <img> tag.

If you do not want to use textile you can just use the regular html <a> tag like this:
<a href="http://www.textpattern.com" target="_blank"><txp:image id="5" /></a>

Last edited by THE BLUE DRAGON (2010-04-26 13:33:31)

Offline

#3 2010-04-26 14:53:52

laptophobo
Member
Registered: 2010-03-01
Posts: 216
Website

Re: Inserting and linking an image

Which plug-in would I need?


Living the Location-Independent Life: www.NuNomad.com

Offline

#4 2010-04-26 15:37:01

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 638
Website

Re: Inserting and linking an image

There are more then one that you can choose from
but I personally always using smd_gallery (Requires TXP 4.2.0+ and smd_lib ) for all my images needs.
<txp:smd_gallery id="5">{url}</txp:smd_gallery>
for showing the thumbnail change {url} with {thumburl}
you can see all the list of attributes and replacement-tags in the plugin help page

Offline

#5 2010-04-26 15:43:36

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 638
Website

Re: Inserting and linking an image

Another Idea for using it for textile will be to use the <txp:site_url /> tag in this way:
!<txp:site_url />images/5.jpg!:http://

Offline

#6 2010-04-26 20:01:31

qrayg
Member
From: USA
Registered: 2004-08-27
Posts: 81
Website

Re: Inserting and linking an image

I just do this:

!/images/image-name.png!:http://domain.com

This is the second post in as many days that people are trying to open new browser windows from links using target=”_blank”. There’s a reason why Textile does not do this. XHTML strict deprecates this attribute making your HTML invalid. There are very few reasons why you would ever need to open a new window from a link, and 99.99999% of cases you can just use a JavaScript modal object.

Also, you should ALWAYS let you user decide if they want the link opened in a new window/tab… ALWAYS. A general rule of thumb, NEVER use target=”_blank”.

1. It’s invalid
2. It’s bad practice
3. It breaks most UI/UX conventions

Offline

#7 2010-04-26 20:09:12

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,942
Website GitHub

Re: Inserting and linking an image

qrayg wrote:

A general rule of thumb, NEVER use target=”_blank”.

… except in Textpattern’s admin interface under the View Site button :-\

Bad TXP spank spank spank


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#8 2010-04-27 01:46:17

laptophobo
Member
Registered: 2010-03-01
Posts: 216
Website

Re: Inserting and linking an image

Thank you. I hadn’t known about the target=blank… = bad practice thing. :-}

In my article, I tried both recommendations (Blue Dragon’s and qrayg’s):

!/images/image-name.jpg!:http://domain.com     and  
!<txp:site_url />images/image-name.jpg!:http://domain.com

The first one worked. HOWEVER, this method requires that I upload an image to the server via FTP. I would rather use the TXP Images manager (since others will be needing to add images and I don’t want them to have direct access to the server.) Can this be done?

The second method did not work. I use the “<txp:site_url/>” tag on my Pages, and it works great, but it simply won’t work on my articles. Why’s that?

Lastly, Bloke stated that I could do something about the target=blank option through the Admin interface. I went through the Admin options and I could see not such thing.

Thanks again for the help here!

Last edited by laptophobo (2010-04-27 01:50:46)


Living the Location-Independent Life: www.NuNomad.com

Offline

#9 2010-04-27 02:55:41

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Inserting and linking an image

laptophobo wrote:

HOWEVER, this method requires that I upload an image to the server via FTP.

You can upload the images with TXP’s uploader if you want.

The second method did not work. I use the “<txp:site_url/>” tag on my Pages, and it works great, but it simply won’t work on my articles. Why’s that?

TXP’s tags do work in articles, just not in that situation because of Textile. Btw, Textile adds the site’s url to the image location so you do not need the tag. Tho, Textile is generated only on article save event which might cause problems when site is moved to different url. When prepending slash is used, no site root url will be added to the image location.

Bloke stated that I could do something about the target=blank option through the Admin interface. I went through the Admin options and I could see not such thing.

No, he didn’t. Bloke made a joke about TXP’s interface and how it uses target attribute in the main menu’s View site link. Language barrier?

Bloke wrote:

Bad TXP spank spank spank

Wait, stop spanking before TXP starts to pixelate. Soon it’s just Pixelpattern, and I tell you, PXP isn’t pretty acronym.

Bad PXP spank spank spank

Last edited by Gocom (2010-04-27 03:09:16)

Offline

#10 2010-04-27 04:00:37

laptophobo
Member
Registered: 2010-03-01
Posts: 216
Website

Re: Inserting and linking an image

Thanks for the quick reply. But I think I need a visual example of how to hyperlink an image within the TXP’s Images manager.

Example of what I use for a non-linked image (using the images stored within Textpattern, NOT my images folder within my server): <txp:image id=“4” />

So, is it possible to add a hyperlink to this tag?

Thanks much.


Living the Location-Independent Life: www.NuNomad.com

Offline

#11 2010-04-27 04:01:38

JanDW
Plugin Author
From: Providence, RI, USA
Registered: 2008-07-18
Posts: 327
Website

Re: Inserting and linking an image

Gocom wrote:

You can upload the images with TXP’s uploader if you want.

laptophobo, when you upload an image within txp, txp changes the filename to its id number, and keeps the extension intact, so you get 1.jpg 2.png 3.jpg …

then you can use: !/images/1.jpg!:http://domain.com

Last edited by JanDW (2010-04-27 04:02:33)


TXPDream – A Textpattern Tag Library for Adobe Dreamweaver. (updated for 4.2.0) | jdw_if_ajax – Only serve certain parts of a page when requested with AJAX

Offline

Board footer

Powered by FluxBB