Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2020-04-08 15:20:12

code365
Member
From: California
Registered: 2009-08-16
Posts: 110
Website

Re: Display single image from an article

@Jakob I viewed the soure code in the browser, don’t see any string path from the image. Should it be <txp:image name=’<txp:category/>.jpg’/>

Could it be the version of txp (latest) I am using, maybe not. I look at the documentation for images tag.

I am using txp images upload tool.

Last edited by code365 (2020-04-09 03:59:13)

Offline

#14 2020-04-08 16:32:59

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,595
Website

Re: Display single image from an article

code365 wrote #322550:

@Jakob I viewed the soure code in the browser, don’t see any string path from the image. Should it be <txp:images name=’<txp:category/>.jpg’/>

In this particular case it should be txp:image not image*s* (i.e. without the ‘s’): maybe that’s the reason nothing’s showing for you?

Also, you mention having folders in Content › Images but I’m not aware of a way to do that. Under Admin › Preferences › Admin you can set your own folder name for all the images instead of using the standard ‘images’ folder. Did you mean that?
Or did you mean perhaps smd_thumbnail? The idea of that is to provide more than two sizes of the same image. If you want a particular size of that image, you’ll need to use <txp:smd_thumbnail name='<txp:category />.jpg' type="your-prenamed-thumbnail-type" />.

If that’s not what you mean, I am perhaps misunderstanding you. This is the step-by-step of the method I suggested:

  1. Upload your image via the Content › Images panel (if not already done)
  2. Edit the image and under Image name in the image information block enter your category name (not the title) exactly as you have it already saved, with .jpg on the end if it is a .jpg. Then save the changes to the image.
  3. In your page template or form code, use what Colak suggested here.
  4. Visit your page in the browser. Make sure you navigate to the right menu item where the image should show. Can you see it?
  5. If it doesn’t, use the shortcut for your browser (as described here) to show the HTML source of the browser code. Have a look through it for the place where the image should appear.
    • If it worked, you should see <img src="path/to/image/your-category-name.jpg"> at the place where it should appear.
    • If the image is broken, you may see another path and may be able to work out why it’s working by comparing it with the working image link.
    • If you get nothing, check your code is working first, by outputting some text instead of the image, e.g. “CATEGORY IMAGE HERE”. If that appears, your code logic is correct. If not, check that first.
    • You can also try outputting <txp:image name='<txp:category />.jpg' /> at a place in your page template where no logic is involved to see if the image link is working.
    • If you still have no luck, try setting the Production status under Admin › Preferences › Site to Debugging and see if you get any error messages that might help you further.

Apologies if I have backtracked too far here, but I am just trying to make sure we’re not talking at cross purposes.


TXP Builders – finely-crafted code, design and txp

Offline

#15 2020-04-08 19:38:50

code365
Member
From: California
Registered: 2009-08-16
Posts: 110
Website

Re: Display single image from an article

@jakob Thank you bro for the information.

Before I read your post I tried the tag below with the name of the image. That worked
<txp:image name=“adirondack-chair-set.jpg” />

I will follow your instructions to track what is going on.

Offline

#16 2020-04-09 10:26:15

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,595
Website

Re: Display single image from an article

Glad it was just the images/image typo and you got it working, and apologies for going back to square 1.


TXP Builders – finely-crafted code, design and txp

Offline

#17 2020-04-09 14:37:00

code365
Member
From: California
Registered: 2009-08-16
Posts: 110
Website

Re: Display single image from an article

Thank you for all your help Jakob
It only works when I type the name of the image.
<txp:image name=“adirondack-chair-set.jpg” />

If I use the category tag it will not work.
<txp:image name=’<txp:category />.jpg’ />

I think I will go back to the previous version.

Offline

#18 2020-04-10 05:37:09

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

Re: Display single image from an article

code365 wrote #322564:

Thank you for all your help Jakob
It only works when I type the name of the image.
<txp:image name=“adirondack-chair-set.jpg” />

If I use the category tag it will not work.
<txp:image name=’<txp:category />.jpg’ />

I think I will go back to the previous version.

Is adirondack-chair-set the name of a category?


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#19 2020-04-11 06:25:07

code365
Member
From: California
Registered: 2009-08-16
Posts: 110
Website

Re: Display single image from an article

Yes, adirondack-chair-set is the name of a category. I think I have tried every image tag, just figure what is wrong.

If I put the name of the image it works <txp:image name=’adirondack-chair-set.jpg’ /> but when I use the category tag inside <txp:image name=’<txp:category />.jpg’ /> it will not work.

This what I did:

I went to content->categories->Images; created an image categories name adirondack-chair-set. I uploaded five images into adirondack-chair-set categories.

I followed the steps above, nothing still not working. It will not display the first image from the article out of the five.

Last edited by code365 (2020-04-11 06:34:26)

Offline

#20 2020-04-11 06:44:25

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

Re: Display single image from an article

Is your site online? I could take a look in order to debug if you wish. Let me know and I’ll send you my email.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#21 2020-04-11 08:09:23

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,595
Website

Re: Display single image from an article

code365 wrote #322572:

This what I did: I went to content->categories->Images; created an image categories name adirondack-chair-set. I uploaded five images into adirondack-chair-set categories.

Thanks for that! We are talking at cross purposes. The code I mentioned / colak provided above assumes article categories, not image categories as it’s the default setting for the type attribute. See the docs for txp:category.

Do you get what you want with

<txp:image name='<txp:category type="image" />' />.jpg" />

To be honest, I’m not sure that will work. You might also need to add type="image" to the category_list tag further up in your code but that may change your menu as well.

If that is the case, you may need to go back and look at how you have organised your site. You can always test these things yourself by outputting txp:category /> on its own (i.e. not as a tag-in-tag) to see what it is giving you.

… It will not display the first image from the article out of the five.

That is a different thing. The discussion we have been having on most of this thread has been about outputting an image ‘linked’ (by name) to the current category (of type article).
In a typical situation, you’d have articles assigned to that category. If you want the image of the first article assigned to that (article) category, go back to colak’s first post. Note: you may need to change the sort order (or date) of your articles to get them to show in the desired order.


TXP Builders – finely-crafted code, design and txp

Offline

#22 2020-04-12 03:50:34

code365
Member
From: California
Registered: 2009-08-16
Posts: 110
Website

Re: Display single image from an article

@jakob and colak thank you so much for your help and time. I understand you guys have been long time txp experts. I will make a donation to txp. If their anyway I can promote txp let me know, it would be my pleasure. Who do I make donation to because I don’t see you guys names.

I am still a txp student :)

Last edited by code365 (2020-04-12 03:52:45)

Offline

#23 2020-04-12 09:21:46

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,595
Website

Re: Display single image from an article

No donation necessary for me personally, but if you want to donate to TXP development, you can find Textpattern’s Donate page on the textpattern homepage (there’s a “Donate” button at the bottom of the main homepage).


TXP Builders – finely-crafted code, design and txp

Offline

#24 2020-04-12 09:48:30

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

Re: Display single image from an article

jakob wrote #322583:

No donation necessary for me personally, but if you want to donate to TXP development, you can find Textpattern’s Donate page on the textpattern homepage (there’s a “Donate” button at the bottom of the main homepage).

+1


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

Board footer

Powered by FluxBB