Advertisement:

Author Topic: [Solved] How to get image url  (Read 2162 times)

Normalu

  • Newbie
  • *
  • Posts: 23
[Solved] How to get image url
« on: March 29, 2015, 03:35:24 am »
I'm trying to get image url in items page

I tried this:
Code: [Select]
<?php echo osc_resource_url(); ?>
but it gives me zero + dot (0.)
I want the full address of the main image like
http://demo.osclass.org/general/oc-content/uploads/115.jpg
but I get
http://demo.osclass.org/general/0.

I searched a lot but couldn't get simple answer

Thanks for helping
« Last Edit: March 29, 2015, 04:21:09 pm by Normalu »

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: How to get image url
« Reply #1 on: March 29, 2015, 02:35:30 pm »
Hi,

You need to use that after some helper has populated 'resources' View variable:

if( osc_count_item_resources() > 0 ) {
    echo osc_resource_url();
 [loop to retrieve images]

OR, if you need it before that, just include this anywhere on item.php:

if( osc_count_item_resources() > 0 )  echo osc_resource_url();

Regards

Normalu

  • Newbie
  • *
  • Posts: 23
Re: How to get image url
« Reply #2 on: March 29, 2015, 04:20:35 pm »
Hi,

You need to use that after some helper has populated 'resources' View variable:

if( osc_count_item_resources() > 0 ) {
    echo osc_resource_url();
 [loop to retrieve images]

OR, if you need it before that, just include this anywhere on item.php:

if( osc_count_item_resources() > 0 )  echo osc_resource_url();

Regards
Thank you very much teseo, it works.

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: How to get image url
« Reply #3 on: November 22, 2017, 05:16:40 pm »
Hi,

You need to use that after some helper has populated 'resources' View variable:

if( osc_count_item_resources() > 0 ) {
    echo osc_resource_url();
 [loop to retrieve images]

OR, if you need it before that, just include this anywhere on item.php:

if( osc_count_item_resources() > 0 )  echo osc_resource_url();

Regards

Teseo, Is there a problem if
if( osc_count_item_resources() > 0 )
is used in header if the page is item page, and the the same function is called in the item.php?

Thank you.

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: [Solved] How to get image url
« Reply #4 on: November 22, 2017, 07:37:13 pm »
Hi,

Better add osc_reset_resources(); after the first time.

Regards

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: [Solved] How to get image url
« Reply #5 on: November 22, 2017, 08:27:40 pm »
Thank you.
Ps.
I tried asigning the result to a variable to not call that function twice, but then it doesn't show the images.