Skip to Content Skip to Menu

🎃 Happy Halloween! Treat yourself with an awesome discount on memberships! Get 20% off now with code SPOOKY-2024!

[SOLVED] How to get the url of image field

  • Roland
  • Roland
  • OFFLINE
  • Posts: 161
  • Thanks: 16
  • Karma: 11
11 years 8 months ago - 11 years 8 months ago #221147 by Roland
Hello,

I made an image-field in CB called cb_banners.

I also made an autoaction that after every update of the image-field it sets the link of the new image in a table per sql (#__banners).

Everything works fine, but if I use [cb_banners] it always set the complete URL with Domain-Name like " simple-quality.de/images/comprofiler/cb_banner_64_5120ad070ebac.jpg " in the field.

For the Joomla-banner-component I just need the path like: "images/comprofiler/cb_banner_64_5120ad070ebac.jpg" without " simple-quality.de/ " in the beginning.

In "#__comprofiler"-table it only saves the file-name like "cb_banner_64_5120ad070ebac.jpg".

Any chanche to get only the filname or the filename with path (without simple-quality.de )?

Greetings, Roland

www.simple-quality.de - The Quality-Web-Portal
Last edit: 11 years 8 months ago by Roland.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48459
  • Thanks: 8280
  • Karma: 1443
11 years 8 months ago #221195 by krileon
Replied by krileon on topic How to get the url of image field
Use CSV output for the fields substitution. Working example as follows.

[cb:userfield field="avatar" output="csv" /]

This will append live_site to it for you. Alternative is to append live_site your self using the below substitution.

[cb:config param="live_site" /]


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • Roland
  • Roland
  • OFFLINE
  • Posts: 161
  • Thanks: 16
  • Karma: 11
11 years 8 months ago #221198 by Roland
Replied by Roland on topic How to get the url of image field
Hello,

the first once don't work..

I used in autoaction: UPDATE `#__banners` SET `params` = '{"imageurl":"[cb:userfield field="cb_banner" output="csv" /]","width":"","height":"","alt":"Simple-Quality-Usermeeting 2013"}' WHERE `id` = '[cb_bannerid]'

And got: {"imageurl":" simple-quality.de/images/comprofiler/cb_banner_64_51224c331cb07.jpg ","width":"","height":"","alt":"Simple-Quality-Usermeeting 2013"}

But I need the url without the live_site: {"imageurl":"images/comprofiler/cb_banner_64_51224c331cb07.jpg","width":"","height":"","alt":"Simple-Quality-Usermeeting 2013"}

Any idea how I can get just the filed-value (filename) without live-site?

Thanks for your help.

Greetings,

Roland

www.simple-quality.de - The Quality-Web-Portal

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48459
  • Thanks: 8280
  • Karma: 1443
11 years 8 months ago #221212 by krileon
Replied by krileon on topic How to get the url of image field
Just build the path manually and add the substitution to it as follows.

images/comprofiler/[cb_bannerid]

Being a query you could also use SQL replacement functions to replace the live site. Example as follows.

REPLACE( '[cb:userfield field="avatar" output="csv" /]', '[cb:config param="live_site" /]/', '' )


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • Roland
  • Roland
  • OFFLINE
  • Posts: 161
  • Thanks: 16
  • Karma: 11
11 years 8 months ago #221225 by Roland
Replied by Roland on topic How to get the url of image field
images/comprofiler/[cb_bannerid]
=> don't work because [cb_bannerid] also gives the complete url (with simple-quality.de ....)

REPLACE( '[cb:userfield field="avatar" output="csv" /]', '[cb:config param="live_site" /]/', '' )
=> The replace works...

Here the query I used in autoaction:
UPDATE `#__banners` SET `params` = CONCAT('{"imageurl":"',REPLACE( '[cb:userfield field="cb_banner" output="csv" /]', '[cb:config param="live_site" /]/', '' ), '","width":"","height":"","alt":"Simple-Quality-Usermeeting 2013"}') WHERE `id` = '[cb_bannerid]'

Thanks a lot!

www.simple-quality.de - The Quality-Web-Portal

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum