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
  • How to deploy WordPress.org Developer theme

    Solved Configure wordpress theme github
    4
    1 Votes
    4 Posts
    3k Views
    phenomlab
    @Hari the real issue here is that I don’t think it can be used as a theme for WordPress because of the dependencies it clearly has, including its own Web server. My view here is that this is designed to be a complete development environment outside of the WordPress core.
  • 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
  • No valid role attribute on elements

    Solved WordPress wordpress
    10
    0 Votes
    10 Posts
    4k Views
    Sala
    I found it here, ins elements can not have aria elements
  • Help us fixing the H1 header tags

    Solved WordPress html h1 tags
    12
    6 Votes
    12 Posts
    4k Views
    phenomlab
    @Sala I’ve spent some time this morning reviewing your WordPress configuration. The issue of the duplicated h1 tag is being caused by AnsPress - you’ll no doubt recall I warned against using this “plugin” (if you can call it that - it’s terrible) here https://sudonix.com/topic/358/fresher-in-nodebb-install/6?_=1674640646763 AnsPress is well-known in WordPress circles for being one of those plugins you’d avoid at all costs. I used it once - never again. It causes far too many issues, and provided you don’t mind your site suffering as a result in terms of performance, bugs, and the like, then ok. In relation to SEO, see the below https://anspress.net/questions/question/seo-issues/ This was reported in October 2022, and it’s still not fixed. From my own independent review, I also see the following issues [image: 81a553b7-acac-43ab-baeb-13d956c41d5f-image.png] The most damaging of these is content being served on both non-www and www URLS, which needs to be fixed ASAP. You’ll note that the h1 heading appears twice (which you’re already aware of) [image: 8065709b-6664-4a50-9cd4-2ca1e9dbe756-image.png] However, aside from SEO, I see far more important issues that you need to resolve first TTFB (Time to First Byte) - the page is incredibly slow to load - in some cases, it takes 2-3 seconds before any content is shown. This is a killer in itself as more than one second loading time is considered far too high. 301 redirects are missing - in this case, you should have a global redirect so that the content is being served from the same domain at all times. The bottom line here, and the “fix” is to remove AnsPress. Clearly, this isn’t palatable from your perspective as there is significant investment on your side. I know from previous discussions that AnsPress was shipped with the theme you are using, but it’s a below-par plugin in terms of performance and stability. You’ll see below my attempts to get AnsPress working as far back as 2017 - I promptly gave up, because it was such a mess https://theme.co/forum/t/anspress-plugin-with-x-pro-integrity-stack/14015 And finally, one very well respected WordPress resource (wpcrafter.com) parted ways with AnsPress in 2018 for similar reasons, which he clearly stated https://anspress.net/questions/question/very-serious-issue-with-upgrade-to-v4-1-9-multiple-emails-being-sent-out-to-everyone/ [image: 262370bb-7d2b-499e-9d89-fac759b1e42d-image.png] At this point, I would weigh up the investment in AnsPress and seriously consider removing it.
  • How to position ads responsively

    Solved WordPress wordpress
    13
    3 Votes
    13 Posts
    4k Views
    Sala
    @phenomlab yes that’s the problem with these J’s, I will try my best , If I find something better I will share. Thanks
  • Flarum - WordPress Journey

    WordPress flarum wordpress quitting
    59
    22 Votes
    59 Posts
    22k Views
    phenomlab
    @Sala I will likely need admin access to your site for this.
  • WordPress site

    General wordpress
    118
    10 Votes
    118 Posts
    61k Views
    JAC
    @jac said in WordPress site: It’s Wordpress OUT, and Ghost IN it seems! *preference based . Even County’s site uses Wordpress . Although that does serve it’s purpose.
  • move out from flarum to wordpress

    WordPress wordpress flarum migration
    87
    52 Votes
    87 Posts
    45k Views
    phenomlab
    @Hari Glad to see this went so well, and that you’ve finally departed the Flarum ecosystem