Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2020-12-01 15:43:21

jayrope
Plugin Author
From: Berlin
Registered: 2006-07-06
Posts: 656
Website

Image associated to a file?

I have a use case here, where I’d need images (and in fact also sound files) associated to particular file downloads, just like article_image works with an article.
I’d love to get around creating individual articles for each of the files in question.
How would you approach this, given, that we have no file_image tag?

Any hints are very appreciated.

Last edited by jayrope (2020-12-01 15:44:55)


a hole turned upside down is a dome, when there’s also gravity.

Offline

#2 2020-12-01 16:32:44

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

Re: Image associated to a file?

I think jcr_file_custom can do what you want. The version on GitHub is for just one extra custom field.

I don’t have a multiple custom field version of that plugin at present, but I made a very similar multi-cf version for the jcr_section_custom, and could apply the same principle to the file custom fields plugin if it was very necessary.


TXP Builders – finely-crafted code, design and txp

Offline

#3 2020-12-01 16:47:50

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 8,451
Website

Re: Image associated to a file?

Or you can be creative with the existing fields:)

<txp:file_download_link id="##"><txp:image id='<txp:file_download_description />' /></txp:file_download_link>

Yiannis
——————————
neme.org | hblack.net | State Machines | NeMe @ github
I do my best editing after I click on the submit button.

Offline

#4 2020-12-01 17:02:53

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

Re: Image associated to a file?

colak wrote #327185:

Or you can be creative with the existing fields:)

True that 👍


TXP Builders – finely-crafted code, design and txp

Offline

#5 2020-12-02 05:32:16

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 8,451
Website

Re: Image associated to a file?

I was thinking that another way is to reverse the connections and use the html semantically defunct image_name if the file description is needed. Here’s a shortcode which may be of use.

<txp:file_download_link id='<txp:images id='<txp:yield name="img" /><txp:image_info type="name" /></txp:images>'><txp:image id='<txp:yield name="img" />' /></txp:file_download_link>

if you name the above form fd, it can be accessed in articles with

<txp::fd img="##" />

Yiannis
——————————
neme.org | hblack.net | State Machines | NeMe @ github
I do my best editing after I click on the submit button.

Offline

#6 2020-12-06 18:22:19

jayrope
Plugin Author
From: Berlin
Registered: 2006-07-06
Posts: 656
Website

Re: Image associated to a file?

Hey, Jakob and Colak, thank you much for your suggestions.

Unfortunately i think none of them is going to work here, because this again would require custom fields for files or one article per file.

I am only using one article to display a list like this
<txp:file_download_list category="dsf" form="files_with_date" label="Daily quick patches - all Vanilla" sort="title asc" />

That’s the reason why i’d need a way to associate an image and/or a soundfile with a particular file independent from any article involved.

That sounds plausible? Or what did i not understand from your suggestions?

I am dreaming of mousing over a title in a file list on a page like below, and just get an image popup ( i can do all the JS) –

Example

Last edited by jayrope (2020-12-06 18:24:28)


a hole turned upside down is a dome, when there’s also gravity.

Offline

#7 2020-12-06 19:05:11

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

Re: Image associated to a file?

jayrope wrote #327301:

That’s the reason why i’d need a way to associate an image and/or a soundfile with a particular file independent from any article involved.

Both the options above should do what you want, whether you try Yiannis’ suggestion to re-use the file_description box or my jcr_file_custom plugin suggested above. Both offer you a way of entering the image ID in the file edit panel without needing a regular article at all. In fact, the readme on the jcr_file_custom GitHub page shows an example that it is quite similar to yours.

I am dreaming of mousing over a title in a file list on a page like below, and just get an image popup ( i can do all the JS) –

That should be perfectly possible with the above.


TXP Builders – finely-crafted code, design and txp

Offline

#8 2020-12-07 12:55:56

jayrope
Plugin Author
From: Berlin
Registered: 2006-07-06
Posts: 656
Website

Re: Image associated to a file?

Jakob, Colak: i want to apologize for not having understood your posts. Should hav read more carefully.

Thank you Jakob for pointing me back to jcr_file_custom.
This works great!
If you find the time to put a second field in there, that would be super extra luxury, but no hurry and in fact maybe i should reactivate some dormant coding skills and just look at the code myself.

Thank you both again. I’d love to refund with some music, want a code for this?

Last edited by jayrope (2020-12-07 12:57:30)


a hole turned upside down is a dome, when there’s also gravity.

Offline

#9 2020-12-07 13:34:11

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

Re: Image associated to a file?

jayrope wrote #327322:

If you find the time to put a second field in there, that would be super extra luxury, but no hurry and in fact maybe i should reactivate some dormant coding skills and just look at the code myself.

Glad it works for you. If you want to try yourself, you can simply transfer the principle already used for my other jcr_section_custom to jcr_file_custom.

EDIT: since then I made the multiple-fields update which you can find at: github.com/jools-r/jcr_file_custom


TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB