Hi - I have a file field inside the event yml. all the events must have a file.
The file can be either an image or a video.
I tried to create an if statement that says: if the file is image show image and if the file is video show a video.
I wrote this bit of code inside the event.php:
When you get this error message, it means that the object ($tmuna->image() in this case) does not exist.
Never use any dynamic class methods without checking if you have an object of this class.
Don’t quite understand why you have two calls to $tmuna->image() although you are checking for the type of the first file in the page. So what are you actually trying to do here? Are you inside a loop?
Hi - thanks for the reply.
I am inside a foreach loop - yes.
I want to detect if the type of the file is a video or an image and according to the result showing either a video tag or an image tag. does it make sense?
I’ve added an if statement before to check if the file exist and inside of it inserted the ‘if video or image statement’. now I managed to remove the error - but the video doesn’t exist. it shows the events with the images but not the video ones (and I have a video file in the content of some events)
Any idea if my code that tries to detect if the file is a video or an image is correct?
This is my new code: