Using php page informations in javascript

It looks like you’re trying to run PHP in a javascript or an HTML file. That won’t work unless you explicitly tell apache to execute .js / .html files as PHP (but you really shouldn’t).

In a kirby template:

<img <?= attr([
    'src' => $image->url(),
    'alt' => '',
    'class' => 'shout-on-hover'
    'data-title' => $image->title()
]) ?> />

In your javascript file:

$('img.shout-on-hover').hover(function() {
  alert($(this).data('title'))
})