Trying to get image src only from Page List thumbnail
Permalink
Hi
I am trying to get the image src only from the thumbnail image from a page list so I can include it as a background image. I have looked all over this forum, stack overflow and getting nowhere. I am new to PHP, so I apologise if this is a really simple request.
I currently have this which is not working
Any ideas what I need to do?
I am trying to get the image src only from the thumbnail image from a page list so I can include it as a background image. I have looked all over this forum, stack overflow and getting nowhere. I am new to PHP, so I apologise if this is a really simple request.
I currently have this which is not working
Any ideas what I need to do?
It is not as simple as one might think.
Using that getTag() function does some work in the background.
First it gets your theme's settings to decide whether the image should be sent back as is or resized. If you theme defines image sizes, you will get a PICTURE tag back. Otherwise a simle IMG tag.
Then it checks whether it should be using thumbnail types (faster and with proper sizing) or legacy thumbnailer (slower and no resizing).
So in the end that tag can be a fully responsive PICTURE tag with several source sets using proerly resized images depending on screen size and one image src for fallback.
In that case, you can't really get the source from the tag and your best move is to just use the tag.
Now if your theme didn't define image sizes, you will get a simple img tag with one source and that will be the path or URL to the full-sized image (so not resized in any way which is a problem if your image is huge)
If you really just want the image src you can but you won't get the benefit of all the work C5 does in the background
you can do either
or
Using that getTag() function does some work in the background.
First it gets your theme's settings to decide whether the image should be sent back as is or resized. If you theme defines image sizes, you will get a PICTURE tag back. Otherwise a simle IMG tag.
Then it checks whether it should be using thumbnail types (faster and with proper sizing) or legacy thumbnailer (slower and no resizing).
So in the end that tag can be a fully responsive PICTURE tag with several source sets using proerly resized images depending on screen size and one image src for fallback.
In that case, you can't really get the source from the tag and your best move is to just use the tag.
Now if your theme didn't define image sizes, you will get a simple img tag with one source and that will be the path or URL to the full-sized image (so not resized in any way which is a problem if your image is huge)
If you really just want the image src you can but you won't get the benefit of all the work C5 does in the background
you can do either
$thumbnail->getRelativePath();
or
$thumbnail->getURL();
The page should have a thumbnail attribute first.