Trying to output path for custom template for the Image block

Permalink
I'm playing round with the image block, trying to duplicate a custom template I built previously that allowed me to pass the path to backstretch to add a full screen background image to my page.

I can't seem to output the path using the variables that are already listed in the core image block and I can't find anywhere in the forums which outlines how to do this.

This is what I've stripped the core image code back to:
<?php defined('C5_EXECUTE') or die("Access Denied.");
$c = Page::getCurrentPage(); {
    $image = Core::make('html/image', array($f));
    $tag = $image->getTag();
}
?>
<script>
    $.backstretch("<?php print $tag;?>");
</script>


and this is what it renders:
<script>
    $.backstretch("<img src="/concrete5.7.2.1/application/files/7414/2049/5444/nature-walk-resized.jpg" alt="nature-walk-resized.jpg" width="1000" height="667">");
</script>


Can anyone help me out and let me know what I need to call to be able to output the path without the html that wraps it.

C5ThemeTeam
 
MrKDilkington replied on at Permalink Reply
MrKDilkington
Hi C5ThemeTeam,

There isn't a lot of documentation on image use in 5.7 yet.

In the meantime, you can use Core::make('helper/image') like 5.6's Loader::helper(‘image’). It has been removed from legacy -https://github.com/concrete5/concrete5-5.7.0/issues/1618... .

This allows you to use getThumbnail() and imagename->src.

Also, I am finishing a block that does this exact thing, but without JavaScript or jQuery dependency. It also supports full screen background images on older browsers (using JavaScript).

I imagine this free block will be ready in the marketplace in a week or two.
C5ThemeTeam replied on at Permalink Reply
C5ThemeTeam
Thanks a million for answering so quickly. I'll look at this again today
BHWW replied on at Permalink Reply
BHWW
Hi it's probably too late now, but incase anyone else wants it... I have managed to extract just the path using:

$image = Core::make('html/image', array($f));
$imagePath = $image->getTag()->src;
tduncandesign replied on at Permalink Reply
tduncandesign
Very helpful, thanks for posting.