Support » Plugin: Private Content » HTML (img src specifically) in the alt= message?

  • Resolved songiuno

    (@songiuno)


    Hi Aldo,

    How feasible would it be to give an ability to link/embed an image in the alt attribute so that instead of specifying text, I could do alt=”<img src=”membersonly.gif” or whatever html markup would produce an icon/emoticon in place of the restricted post? Just a thought, nothing worth your time if it’s considerable work.

    Sorry, must be the lack of other external stimulus, given the world situation, that I’m toying with ideas! Hope everyone is doing well and staying healthy.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Aldo

    (@aldolat)

    Hi @songiuno,
    it’s possible using a filter. The plugin has several filters, that you can use for modifying something.

    In our case, the filter hook is ubn_private_text_empty. This filter is executed when the text is empty, i.e. when the reader of a given page hasn’t any right to read that given paragraph.

    For example, here is a function that can be added in the functions.php file of the current theme:

    function image_when_private_content_is_empty( $text ) {
    	$text = '<img src="' . get_stylesheet_directory_uri() . '/images/members.png" alt="" />';
    
    	return $text;
    }
    add_filter( 'ubn_private_text_empty', 'image_when_private_content_is_empty' );

    If the user cannot read the paragraph, the plugin will display the image members.png, as in this screenshot:

    The line with gray background is the used shortcode, and the image is the result.

    Hope everyone is doing well and staying healthy.

    We are all fine, in this moment. I hope that you all are fine too. 🙂

    Thank you, thank you! Works like a charm!

    Plugin Author Aldo

    (@aldolat)

    You’re welcome!

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.