Jump to content

Recommended Posts

Posted

Hi,

Could someone give me a helping hand please?

I have the below code:

<?php 
// Show the gallery widget if there are slideshow images attached to this press article
if(count($page->slideshow_images)) {
	echo '<div id="article_slideshow_widget">';
	$n = 0;
	echo "$page->images->first()->url;<img src='http://i.imgur.com/0heduk5.png' class='article_slideshow_widget_zoom'></div>";
	$n++;
	}
	echo "";
?>

I want to output the first image from the images field in the article_slideshow_widget div, but it is only giving me the filename currently (I removed the img tags to see what was being output as I was being given a broken image as the complete URL isn't there!)

Sure I'm close but would really be grateful for a pointer.

Thanks so much

Jon

Posted

Try to set the image url to a variable first:

$n = 0;
$image_url = $page->images->first()->url;
echo "{$image_url}<img src...
Posted

Or if inside a string and multiple chains use {}

echo "{$page->images->first()->url}...";

If only one chain it doesn't need it like

echo "$page->url";

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...