Social Images missing from

#232806
  • Resolved Ig Marketing Dev
    Rank Math free

    Hi there,

    We just recently noticed an issue regarding the meta tags for facebook and twitter. Specifically, we found that the opengraph and twitter image meta tags were completely missing from the head. Looking through the help/support forums, I found this article to troubleshoot the issue and narrowed things down to our custom template.

    Investigating our template, I found that the issue seems to stem from a few lines of code that make use of the restrict_mimes_for_author() function.


    add_filter('upload_mimes','restrict_mimes_for_author');
    function restrict_mimes_for_author($mimes) {
    if (!current_user_can('administrator') && !current_user_can('editor')) {
    return;
    }

    ....Rest of code
    }

    When commenting out the entire function or simply the 3 lines of the if condition, the content appears in the header. If it’s exists, I can only see it in the HTML when viewing while logged into an admin or editor account.

    Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hello,

    Thank you for contacting us and sorry for any inconvenience that might have been caused due to that.

    Without seeing much information about the function it seems to be restricting the allowed image types in your website and only lifting the restrictions for certain users.

    Since you already narrowed down the issue to the custom template we would recommend getting in touch with the theme providers to look for ways to improve on that function without creating any conflicts.

    ​​​​​​​Don’t hesitate to get in touch if you have any other questions.

    Hello,

    I have updated the sensitive data as requested. Can you please check further?

    Thank you.

    Hi Miguel,

    Thank you for the quick response! Actually, this is a custom theme that we developed.

    The function in question is simply leveraging the upload_mimes wordpress hook to enable SVG uploads to the media library. The lines that seemingly cause the conflict is the if condition to restrict certain users from uploading the SVGs — for instance, only admins and editors can upload them.

    We don’t want to deviate from this functionality, but any help that can avoid the conflict while maintaining the functionality would be greatly appreciated πŸ™‚

    Thanks!

    Hello,

    Could you please try to make a little modification to your function and in the first return, inside the if statement, return the default mimes list?

    
    return $mimes;
    

    Let us know if this helps solve your issue.

    Looking forward to hearing back from you.

    Hi Miguel, that did the trick! Thank you so much for the help!

    Hello,

    We are super happy that this issue is already resolved. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind us asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

Viewing 6 replies - 1 through 6 (of 6 total)

The ticket ‘Social Images missing from’ is closed to new replies.