• Resolved Mehmet Baris

    (@gecedergi)


    hi @cdog

    the first: i am using your plugin on my website and this is very usefull, thanks a lot for that.

    but i have a question about this plugin.

    i want to echo a custom avatar image url (just url) on a template php page.

    for example, if an user dont want to use Gravatar:
    he can set a custom avatar on the profile page. and i want to echo this spesific avatar url to echo somewhere. just url, for examle: “example.com/wp-content/uploads/2017/07/example.jpg”

    i tried a lot of method but i can’t get any solution.

    is there any option about that?

    thanks for interest.

Viewing 1 replies (of 1 total)
  • Thread Starter Mehmet Baris

    (@gecedergi)

    hello everyone.

    i contacted the plugin author and he created a perfect solution for me. i want to thank him once more.

    and i wanted to share the solution.

    the first one: this plugin(Avatar Manager) make an option to set a custom avatar for every author by one by except for the Gravatar.

    and

    if you want to echo an author custom avatar image url (just url, except for img or etc. tags) in a specific page or meta tag: you can use this code. this code written by the plugin author ( @cdog )

    <?php
    $my_custom_avatar = get_avatar(get_the_author_meta( 'ID' ), 400 );
    $document = new DOMDocument();
    @$document->loadHTML($my_custom_avatar);
    $nodes = $document->getElementsByTagName('img');
    echo $nodes->item(0)->getAttribute('src'); ?>

    this code will echo an author(filter by id) custom avatar image url to any of php page.
    the number of “400” in the code is the image crop size. you can change what size you want to crop.

    for usage example:

    you can use the avatar image url for an author personal page. (for ex: https://www.example.com/author/admin)

    or on a html meta tag for SEO (for ex: meta itemprop image, meta twitter:image, meta og:image)

    many thanks.

    • This reply was modified 7 years, 4 months ago by Mehmet Baris. Reason: spell check
    • This reply was modified 7 years, 4 months ago by Mehmet Baris. Reason: spell check
Viewing 1 replies (of 1 total)
  • The topic ‘can we echo just the custom avatar url?’ is closed to new replies.