简体   繁体   English

使用php填充背景图像的title属性

[英]Populate title attribute of background-image using php

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? 我怎么能够达到这个结果呢?

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. 我觉得你在这里遇到麻烦,我不知道能够附加到通过CSS传递的内容的属性,这是图形选择器中的style属性。

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? 如果是这样,为什么不将图像作为HTML图像元素,然后在要放在背景图像上的内容上使用CSS和position:absolute

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM