Announcement

Collapse
No announcement yet.

Show pictures in post only to members

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #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 customization and demonstration site.
    vBulletin 5 Documentation - Updated every Friday. Report issues here.
    vBulletin 5 API - Full / Mobile
    I am not currently available for vB Messenger Chats.

    Comment


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

      GIPHY for vB5 | AutoLinker | Video Attachments Player | Audio Attachments Player | Clear System Cache Cron | Drag-n-Drop Upload | Topic AJAX AutoUpdate | Force Read Topic | and a lot more...

      Comment


      • #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


        • #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

          TalkNewsUK - My vBulletin 5.4.4 Demo
          AdminAmmo - My Cloud Demo

          Comment


          • #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


            • #7
              Originally posted by Oore View Post
              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 customization and demonstration site.
              vBulletin 5 Documentation - Updated every Friday. Report issues here.
              vBulletin 5 API - Full / Mobile
              I am not currently available for vB Messenger Chats.

              Comment


              • #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:	1
Size:	39.5 KB
ID:	4386549

                Comment


                • #9
                  Hello,

                  Is there anybody with some information on that?

                  The issue still persists.

                  Thanks in advance!

                  Oore

                  Comment


                  • #10
                    As mentioned by Wayne, this is outside the scope of the support we can provide.
                    MARK.B | vBULLETIN SUPPORT

                    TalkNewsUK - My vBulletin 5.4.4 Demo
                    AdminAmmo - My Cloud Demo

                    Comment


                    • #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


                      • #12
                        Originally posted by josueinaki View Post
                        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 customization and demonstration site.
                        vBulletin 5 Documentation - Updated every Friday. Report issues here.
                        vBulletin 5 API - Full / Mobile
                        I am not currently available for vB Messenger Chats.

                        Comment

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