Show pictures in post only to members

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Oore
    Member
    • Oct 2017
    • 62
    • 5.3.x

    Show pictures in post only to members

    Hello,

    Is it possible to replace the picture in a post by a message like "Pictures are only shown to registered and logged in members"?

    Currently instead of the picture a link is shown when not being logged in.

    For attachments I have found the CSS code posted here to achieve that.

    Thanks in advance!

    Oore
  • Wayne Luke
    vBulletin Technical Support Lead
    • Aug 2000
    • 73981

    #2
    The IMG BBCode? It should be possible with similar CSS. Try this:
    Code:
    [data-usergroup-id='1'] .js-post__content-text > img::before {
      content: "Please Register to View Images."
    }
    
    [data-usergroupid="1"] .js-post__content-text > img::before {
      display:none;
    }
    Caveats: The image will still be in the code so if they go digging for it, they can still find it. Plus this will hide the Smileys (Emoticons).

    A more comprehensive solution would require custom coding.
    Translations provided by Google.

    Wayne Luke
    The Rabid Badger - a vBulletin Cloud demonstration site.
    vBulletin 5 API

    Comment

    • glennrocksvb
      Former vBulletin Developer
      • Mar 2011
      • 4011
      • 5.7.X

      #3
      Self-closing HTML tags such as <img>, <input>, etc cannot have pseudo elements :before and :after.
      ​​​​​​

      Flag Icon Postbit Insert GIPHY Impersonate User BETTER INITIALS AVATAR Better Name Card Quote Selected Text Bookmark Posts Post Footer Translate Stop Links in Posts +MORE!

      Comment

      • Oore
        Member
        • Oct 2017
        • 62
        • 5.3.x

        #4
        The CSS code would only affect the image, but when the user is logged in no image is shown. Instead a link to the image is displayed.

        Is there a way to modify the internal BB code [ATTACH=JSON] ? Then I could add a div around and make the <a href> via CSS disappear completely.

        Comment

        • Mark.B
          vBulletin Support
          • Feb 2004
          • 24286
          • 6.0.X

          #5
          Try this additional css:

          Code:
          /* Hide Images From Guests */
          
          [data-usergroupid="1"] .photo-preview {
            display:none;
          }
          
          [data-usergroupid="1"] .gallery-details::before {
            content: "This post contains images - please register or log in to view them"
          }
          
          [data-usergroupid="1"] .gallery-details .b-photo-count {
            display:none;
          }
          
          [data-usergroupid="1"] .b-post-attachments ul::before {
            content: "This post contains images - please register or log in to view them"
          }
          
          [data-usergroupid="1"] .b-post-attachments .b-post-attachments__item {
            display:none;
          }
          
          /* End Hide Images From Guests */
          MARK.B
          vBulletin Support
          ------------
          My Unofficial vBulletin 6.0.0 Demo: https://www.talknewsuk.com
          My Unofficial vBulletin Cloud Demo: https://www.adminammo.com

          Comment

          • Oore
            Member
            • Oct 2017
            • 62
            • 5.3.x

            #6
            Thanks Mark! This piece of code is working fine for attachments and galleries.

            Unfortunately it isn't for images embedded in the post ([ATTACH=JSON]...[/ATTACH]), because they are rendered to "<a href=''><img...></a>" when not being logged in.

            Is there a way to modify the rendering and add an outer <div> or <span>? Then it would be easy to use the CSS code you provided.

            Comment

            • Wayne Luke
              vBulletin Technical Support Lead
              • Aug 2000
              • 73981

              #7
              Originally posted by Oore
              Thanks Mark! This piece of code is working fine for attachments and galleries.

              Unfortunately it isn't for images embedded in the post ([ATTACH=JSON]...[/ATTACH]), because they are rendered to "<a href=''><img...></a>" when not being logged in.

              Is there a way to modify the rendering and add an outer <div> or <span>? Then it would be easy to use the CSS code you provided.
              You would need to modify or override the handle_bbcode_img2() method in class vbCodeParser. This is in the class_bbcode.php file in /core/includes/. This is outside the scope of support.
              Translations provided by Google.

              Wayne Luke
              The Rabid Badger - a vBulletin Cloud demonstration site.
              vBulletin 5 API

              Comment

              • Oore
                Member
                • Oct 2017
                • 62
                • 5.3.x

                #8
                Sounds great, Wayne!

                I have tried modifying the returned values of this function, but it isn't showing any change. Do I have to do something to see the modifications (e.g. wiping a cache, etc.)?

                Only to be sure, I was referring to modifying this piece of code a user is getting displayed when being not logged in. I would like to added a <div> around the <a...> tags.

                Click image for larger version

Name:	picture.jpg
Views:	174
Size:	39.5 KB
ID:	4386549

                Comment

                • Oore
                  Member
                  • Oct 2017
                  • 62
                  • 5.3.x

                  #9
                  Hello,

                  Is there anybody with some information on that?

                  The issue still persists.

                  Thanks in advance!

                  Oore

                  Comment

                  • Mark.B
                    vBulletin Support
                    • Feb 2004
                    • 24286
                    • 6.0.X

                    #10
                    As mentioned by Wayne, this is outside the scope of the support we can provide.
                    MARK.B
                    vBulletin Support
                    ------------
                    My Unofficial vBulletin 6.0.0 Demo: https://www.talknewsuk.com
                    My Unofficial vBulletin Cloud Demo: https://www.adminammo.com

                    Comment

                    • josueinaki
                      Senior Member
                      • Sep 2015
                      • 199
                      • 5.1.x

                      #11
                      Hello, I tried some time ago make some thing like that but for links, I will share here the info I got in that time, this could be usefull for this too
                      https://www.vbulletin.com/docs/html/...e_conditionals < vbulletin manual showing how to use to set conditionals for some group

                      <vb:if condition="$bbuserinfo['userid'] == 0">//you need one more conditional here to filter only images
                      <p>Register for view links
                      <br />
                      </p>
                      <vb:else />CODE LINK OR CODE BB CODE HERE
                      </vb:if>
                      Use php hooks to make this work, good luck

                      Comment

                      • Wayne Luke
                        vBulletin Technical Support Lead
                        • Aug 2000
                        • 73981

                        #12
                        Originally posted by josueinaki
                        Hello, I tried some time ago make some thing like that but for links, I will share here the info I got in that time, this could be usefull for this too
                        https://www.vbulletin.com/docs/html/...e_conditionals < vbulletin manual showing how to use to set conditionals for some group

                        <vb:if condition="$bbuserinfo['userid'] == 0">//you need one more conditional here to filter only images
                        <p>Register for view links
                        <br />
                        </p>
                        <vb:else />CODE LINK OR CODE BB CODE HERE
                        </vb:if>
                        Use php hooks to make this work, good luck
                        That page isn't a vBulletin 5.X document page and incorrect information for this version of the software. You can tell it isn't a page in the version of manual selected because the breadcrumb and left navigation menu are broken.
                        Translations provided by Google.

                        Wayne Luke
                        The Rabid Badger - a vBulletin Cloud demonstration site.
                        vBulletin 5 API

                        Comment

                        widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                        Working...