-
AuthorPosts
-
November 2, 2019 at 10:14 am #1153211
Hello. On my site I have uploaded an image, and intentionally left its ‘title’ field blank. I then created a blog post and added this image as the featured image for that post. When I view the post, the featured image displays as expected and as desired. But the title on it is not blank as expected/desired. The title is set to the title of the blog post (screenshots). Why is that occurring and how can I resolve it? I will share my login details in the private content.
Thanks.
November 3, 2019 at 3:49 am #1153434Hey FeedXL2019,
Thanks for the screenshots and link, this is for low vision accessibility because all browsers don’t read the alt tag of images.
To remove the titles Try adding this code to the end of your functions.php file in Appearance > Editor:function custom_script(){ ?> <script> jQuery(window).load(function(){ jQuery('a').removeAttr('title'); jQuery('img').removeAttr('title'); }); </script> <?php } add_action('wp_footer', 'custom_script');
Best regards,
MikeNovember 3, 2019 at 7:46 am #1153472or do not remove it but redefine it to an empty title:
jQuery('your-selector').attr('title', ' '); or via property: jQuery('your-selector').prop('title', ' ');
November 3, 2019 at 9:38 am #1153474Hi Mike and Guenni007. Thanks for the reply and I appreciate your suggestions. But to be clear, both of those are workarounds–extra code to cover up what appears to be a bug. What about an actual solution to the issue–one that ensures the title attribute on the page is set to the value I assign it in the WordPress media library?
For example, both of your suggestions will ensure the title attribute is blank. But what if I don’t want it blank? What if I want to set the title attribute to the value defined in the WordPress media library? With your workarounds it seems like I would have to add custom code on a per-image basis.
Thanks.
November 4, 2019 at 1:37 pm #1153694Hi,
Sorry, from your screenshots you showed an empty title field in the media library, so I thought you just wanted to remove the post title, so I didn’t find a solution for this and I’m asking the team for advice. Thank you for your patience.Best regards,
MikeNovember 5, 2019 at 8:20 am #1153886Yep, my fault for not being clear on that. Thanks for passing this up to the team.
November 6, 2019 at 6:46 pm #1154381November 8, 2019 at 12:38 pm #1154962OK thanks for that. I see that the title attribute on the image is being set to $featured_img_desc. Earlier in the file, in lins 152-154, that variable is set to the post excerpt by default. Only when the post excerpt is blank will that variable be set to the image’s actual title attribute. Am I understanding that correctly?
Those lines are:
$desc = get_post( get_post_thumbnail_id() ); if(is_object($desc)) $desc = $desc -> post_excerpt; $featured_img_desc = ( $desc != "" ) ? $desc : the_title_attribute( 'echo=0' );
November 8, 2019 at 1:42 pm #1154997Hi FeedXL2019,
Yes, this seems correct.
Best regards,
VictoriaNovember 9, 2019 at 11:37 am #1155198OK. So isn’t that a bit non-standard and undesirable? Why is the theme overriding the title attribute that I set in WordPress media library? The sole purpose of that field is to allow me to set the title attribute to anything I want.
November 12, 2019 at 6:42 pm #1156077Hi FeedXL2019,
Unfortunately, I cannot tell you why it is done like this. However, you can override this behavior.
Best regards,
VictoriaNovember 13, 2019 at 4:35 am #1156260>> Unfortunately, I cannot tell you why it is done like this.
OK. But can you perhaps ask someone who knows the answer? Or transfer me to someone who can answer that question? Or perhaps point me to another forum in which I can ask this question (e.g. GitHub)?
>> However, you can override this behavior.
Yes I realize that. But on the surface, this looks like a theme bug that should be corrected in the theme code base by theme devs–wouldn’t you agree?
November 15, 2019 at 10:12 am #1157115Hi,
Thank you for the update.
We are not really sure about the actual logic behind it, but the first thing that comes to mind is to keep the title attribute filled, so it’s not empty. You can always override the template in the child theme if you don’t really need to add a description for the featured featured image using the the title attribute. It can be considered as a bug or an error if the title or the description field is not working.
Best regards,
IsmaelNovember 15, 2019 at 10:25 am #1157123>> We are not really sure about the actual logic behind it,
Then who is? Can I speak with that person? Or can you pass along my questions to that person? I asked you these questions in my previous message, but you ignored them :-( This ticket is nearly two weeks old now, and there still hasn’t been much movement. If I could speak with someone who is actually familiar with the code and the logic behind it, it would speed things up.
November 18, 2019 at 5:57 am #1157749Hi,
Then who is? Can I speak with that person?
Kriesi is quite busy right now, so he might not be able to answer this thread immediately. We will tag one of our developers to check the thread, but he will probably tell you the same — that the purpose of the current code is to keep the title attribute filled — it’s arbitrary. Again, you can always override the template in the child theme if you want to keep the title attribute empty. Let us know if you require assistance with it.
Best regards,
IsmaelNovember 18, 2019 at 11:38 am #1157802>> We will tag one of our developers to check the thread
Please do so. I would like to speak with a developer as soon as I can. It has been 16 days now, and there has been zero movement on this issue :-(
Thanks.
November 18, 2019 at 12:55 pm #1157852Hey!
Sure thing. He might not respond immediately, so you might wait for a while. Again, if all you want to do is remove the title, you can always edit the includes > loop-index.php template as previously suggested. Look for this code around line 154:
$featured_img_desc = ( $desc != "" ) ? $desc : the_title_attribute( 'echo=0' );
Replace it with:
$featured_img_desc = ( $desc != "" ) ? $desc : '';
This modification will keep the $featured_img_desc variable empty when the description field is empty.
Regards,
IsmaelNovember 19, 2019 at 8:40 am #1158047>> He might not respond immediately, so you might wait for a while.
OK. Can you give me an estimate? Are you talking about weeks, months, years? I paid for support, and just want some questions answered.
>> Again, if all you want to do is remove the title,
If you read what I’ve already written in this post, I’ve explained that removing the title is not all I want to do.
November 21, 2019 at 10:06 am #1158765Hi,
Thank you for the update.
If we read the post correctly, you wanted to use the value of the title field instead of the image caption or description as the value of the featured image’s title attribute. Please edit this line in the same file..
if(is_object($desc)) $desc = $desc -> post_excerpt; $featured_img_desc = ( $desc != "" ) ? $desc : the_title_attribute( 'echo=0' );
.. and replace it with:
if(is_object($desc)) $desc = $desc -> post_title; $featured_img_desc = ( $desc != "" ) ? $desc : '';
Best regards,
IsmaelNovember 27, 2019 at 6:30 am #1160563Well you’re still not exactly understanding what I want. I don’t want to insert the post title–I want to insert the ‘title’ attribute for the image in-question. But no worries–I have enough so that I can move forward with a solution on my own. Thanks for the help. I have one last question though. I am going to copy the file /includes/loop-index.php to my child theme, and make edits to it. Just so I know, other than individual blog posts, what other pages execute this file (loop-index.php)?
Thanks.
November 28, 2019 at 3:08 am #1160853Hi,
I don’t want to insert the post title–I want to insert the ‘title’ attribute
We do understand you’re inquiry. The post_title in that modification refers to the title attribute of the featured image, not the title of the actual post.
what other pages execute this file (loop-index.php)?
It’s also used in the archive.php template.
Best regards,
IsmaelNovember 28, 2019 at 7:23 am #1160872>> We do understand you’re inquiry. The post_title in that modification refers to the title attribute of the featured image, not the title of the actual post.
OK my mistake–I was a bit hasty. You are correct.
>> It’s also used in the archive.php template.
OK thanks. So any page that has ‘Archives’ as the value for ‘Template’ (example) would execute loop-index.php. Am I understanding that correctly?
November 28, 2019 at 7:43 am #1160875Hi,
Thank you for the update.
The custom Archive template doesn’t use the loop-index.php file, only the default archives template like archives.php, tag.php files, index.php and the default blog element or config-templatebuilder > aviashortcodes > blog.php file. Try to look for this line:
get_template_part( 'includes/loop', 'index' );
Best regards,
IsmaelNovember 28, 2019 at 10:41 am #1160898OK let me ask my question in a different way. Let’s say I have 50 pages on my site. How can I determine which of them execute loop-index.php?
November 29, 2019 at 10:55 am #1161172Hi,
Those pages containing a Blog Posts element — assuming that they are built using the ALB and that the blog layout is set accordingly — will execute the loop-index.php file.
If you have any additional questions at this time we kindly ask that you open them up in a separate thread. The longer threads get in the forum, they become more difficult to support as they tend to drift off topic and they also make it troublesome for users trying to search for solutions. Keeping threads relevant to their original inquiry ensures that we can keep better track of what has been resolved and that users can more effectively find answers to similar issues they might be experiencing.
Thanks!
Best regards,
IsmaelNovember 29, 2019 at 11:07 am #1161176OK thanks. We can consider this resolved.
November 29, 2019 at 11:57 am #1161198Hi,
Glad Ismael could help, we will close this now. Thank you for using Enfold.For your information, you can take a look at Enfold documentation here
For any other questions or issues, feel free to start new threads in the Enfold forum and we will gladly try to help you :)Best regards,
Mike -
AuthorPosts
- The topic ‘Featured image 'title' is not as expected.’ is closed to new replies.