1

I want to credit the author of a few the photos on my website in the title tag. I just added the fields in the admin sections using the instructions given here and this works fine.

Now i want to display that information in the title tag of a photo but that photo is set as a background image and therefor im not able to add a title tag to it and thus the info isnt showing. It is said as a background-image because it sometimes has an extra layer (partially) on top of it.

<figure 
    style="<?php echo "background-image:url('".$snakeImageUrl."'); background-size:cover;"; ?>" 
    title="<?php echo get_post_meta($post->ID, 'be_photographer_name', true); ?> 
    <?php echo get_post_meta($post->ID, 'be_photographer_url', true); ?>">
</figure>

How am i still be able to achieve this result?

Alesis
  • 194
  • 3
  • 17
  • title should work for figure-tag. What is the result in plain HTML? What are the css-values of the tag? I ask this, because, when your element has 0x0 dimensions, you will never get the title shown. – Oliver Feb 17 '17 at 15:26
  • Title does work for a figure however as the image url is also either set as a background-image or loaded dynamically i dont think it is able to connect image with the other info as they are both loaded seperatly. – Alesis Feb 17 '17 at 15:35

1 Answers1

0

I think you're going to have trouble here, I don't know of properties being able to be attached to content that's delivered via CSS which is what the style attribute within with figure selector is.

Can you edit the template? If so, why not have the image as a HTML image element and then use CSS and position:absolute on the content that you want placed over the background image?

Daniel
  • 2,167
  • 5
  • 23
  • 44