Creating my custom API, but got one small problem:
content: {
cover: '- mycover.jpg'
}
images: [
{
filename: 'mycover.jpg'
},
{
filename: 'anotherimage.jpg'
}
]
So problem is, that I want to compare with given cover name and add boolean to exact image (if its cover image). But cover image name has unnecessary dash at front. In this case I can not compare exact names, but need to check if one name includes another. Maybe there is some function which returns clean cover image name without dash at the front?
Currently I came up with something like this:
$coverName = $item->cover()->value();
$imageName = $image->filename();
if (strpos($coverName, $imageName) !== false) {
$imageData['cover'] = true;
}
But maybe there is more elegant way?