Skip to content

How to fix no img attribute from this code

Solved WordPress
7 2 2.2k 1
  • wrote on last edited by
    #1

    I’m having a lot of trouble getting the code below to echo either the profile title or just a manual text “profile image” as the image attribute.

    <a class="bs-author-pic mb-3" href="<?php echo esc_url(get_author_posts_url( get_the_author_meta( 'ID' ) ));?>"><?php echo get_avatar( get_the_author_meta( 'ID') , 150); ?></a>
    

    This code derive from page article where it shows the author image. i.e https://sopriza.com/men-should-never-ignore-these-5-symptoms/

  • wrote on last edited by
    #7

    Yes, I am aware that if users are given the option to enter alt text, some may do so in an abusive manner. For the time being, we’ve adjusted the php script to generate the alt automatically, thus there are no longer any SEO problem with alt images.

  • I’m having a lot of trouble getting the code below to echo either the profile title or just a manual text “profile image” as the image attribute.

    <a class="bs-author-pic mb-3" href="<?php echo esc_url(get_author_posts_url( get_the_author_meta( 'ID' ) ));?>"><?php echo get_avatar( get_the_author_meta( 'ID') , 150); ?></a>
    

    This code derive from page article where it shows the author image. i.e https://sopriza.com/men-should-never-ignore-these-5-symptoms/

    wrote on last edited by
    #2

    @Sala you’re missing the alt attribute

    See below for a basic example
    https://www.w3schools.com/tags/att_img_alt.asp

  • @Sala you’re missing the alt attribute

    See below for a basic example
    https://www.w3schools.com/tags/att_img_alt.asp

    wrote on last edited by
    #3

    @phenomlab thanks for quick reply, my problem is how can i deploy the alt attribute inside the code above?

  • @phenomlab thanks for quick reply, my problem is how can i deploy the alt attribute inside the code above?

    wrote on last edited by
    #4

    @Sala you can either use a WordPress plugin to do it for you, or a jQuery function. How is the image being uploaded?

  • @Sala you can either use a WordPress plugin to do it for you, or a jQuery function. How is the image being uploaded?

    wrote on last edited by Sala
    #5

    @phenomlab The image is being uploaded using an inbound, right from the registration form

  • @phenomlab The image is being uploaded using an inbound, right from the registration form

    wrote on last edited by
    #6

    @Sala said in How to fix no img attribute from this code:

    The image is being uploaded using an inbound, right from the registration form

    I guess the next question here is how do you apply an alt description to an image that is being uploaded to make sure it is unique? What value are you expecting here, and does it make more sense to ask the user to “describe” the image they are uploading? You’d probably also want some control over what is being entered there to ensure it complies with site policies etc…

  • wrote on last edited by
    #7

    Yes, I am aware that if users are given the option to enter alt text, some may do so in an abusive manner. For the time being, we’ve adjusted the php script to generate the alt automatically, thus there are no longer any SEO problem with alt images.

  • phenomlab phenomlab has marked this topic as solved on

Did this solution help you?
Did you find the suggested solution useful? Support 💗 Sudonix with a coffee ☕
If your organisation needs deeper expertise around infrastructure, security, or technology leadership, learn more about Phenomlab Ltd. Many of the deeper technical guides behind Sudonix are published there.

Related Topics
  • configure ghost and wordpress combo

    Moved Solved WordPress ghost wordpress nginx
    9
    7 Votes
    9 Posts
    3k Views
    phenomlab
    @Madchatthew I’d always post for the reasons I stated above. It’s useful information and could save someone else the headache.
  • Rotating Star Effect

    Solved Let's Build It wordpress css
    17
    12 Votes
    17 Posts
    5k Views
    Hari
    @phenomlab thanks a lot for these, both of the below are awesome! https://codepen.io/bennettfeely/pen/vYLmYJz https://codepen.io/C-L-the-selector/pen/MWZbWBo
  • WP / Woocommerce Mystery

    Solved Configure wordpress
    23
    1
    12 Votes
    23 Posts
    11k Views
    phenomlab
    @Panda said in WP / Woocommerce Mystery: Just back to my other question, have you ever used Shopify? It insists on a templating language to use any custom js. Not personally as never had any need, however, I do know that it uses Liquid for JS templating. It’s written in Ruby and is used to generate dynamic content on shop fronts. There’s zero reason as to why it wouldn’t work with data supplied by 3rd party API’s, although WordPress code won’t natively work for obvious reasons, and as such, this code would need to be re-written. The JS part will likely work with minor modification, but not the PHP file in it’s current form.
  • 2 Votes
    11 Posts
    3k Views
    Hari
    Thanks for your inputs ️
  • Fixing YouTube videos css

    Solved WordPress css
    8
    2 Votes
    8 Posts
    3k Views
    Sala
    @phenomlab It looks good, but not anymore. I’ve already lost so much time. Now it’s time to move on
  • auto create flarum new discussions in wordpress

    Configure flarum wordpress
    2
    1 Votes
    2 Posts
    1k Views
    phenomlab
    @Hari I think you’re referring to this https://sudonix.com/topic/170/creating-posts-from-rss-feeds-in-flarum However, this code was never designed to work with WordPress, but you could leverage the WP-CLI to do something similar without too much effort.
  • Best Cloudflare settings for woo commerce

    Solved WordPress cloudflare wordpress woocommerce
    2
    1
    1 Votes
    2 Posts
    2k Views
    phenomlab
    @hari the cache level for woocommerce should always be bypass. Any caching of woocommerce will cause you serious issues and will result in the checkout process not functioning correctly. This does mean that the overall experience will be slower (depending on geographic location) although CF is known to cause significant issues hence the need to bypass. If you want to cache as much as possible, then set rules to bypass caching on the cart and account pages etc.
  • WordPress & NodeBB

    Solved WordPress
    6
    0 Votes
    6 Posts
    3k Views
    phenomlab
    @jac That won’t matter. You just redirect at nginx or apache level and it’ll work. The generally accepted standard though is to use a subdomain.