Skip to content

CSS code customization for the link preview plugin

Solved Customisation
  • Hi @phenomlab ,

    I am working on CSS codes to customize the link-preview plugin for some time, but I was unsuccessful 😄 so, I wanted to consult you in case I am missing an important line…

    Unfortunately, normal previews of this plugin are too big for our taste, just like how iframely used to be…

    https://sudonix.org/post/4083

    I ended up something like this:

    .post-container .content .card {
        display: contents !important;  
    }
    
    .link-preview {
        
        .card-img-top {
            height:120px !important;
            width: auto !important;
            overflow: hidden !important;        
            float: left !important;
            padding: 0 5px 0 0 !important;      
        }
        
        .card-body {
            padding: 1px 1px 1px 1px !important;
        }
        
        .card-footer {
            position: relative !important;    
        }
    }
    

    But this is nowhere near close to what I was aiming…

    This is how it used to be with iframely and what we are aiming:
    Screenshot 2024-04-02 at 22.04.41.png

    This is how ugly it looks right now 😄

    Screenshot 2024-04-02 at 22.02.51.png

    I hope you can help with this transformation 😄
    Thanks,

  • @crazycells technically possible, yes - I can get somewhere near the desired layout as below

    7b646096-5c21-44a1-b283-54d6f94e579b-image.png

    However, this isn’t great from the CSS perspective as it’s something of a hack, and will not look good on mobile devices. Here’s the CSS for that if you want to use it.

    .post-container .content .card {
        display: contents !important;  
    }
    .link-preview .card-title {
        margin-left: -238px;
        float: left;
    }
    .link-preview .card-img-top {
        height: 120px !important;
        width: auto !important;
        overflow: hidden !important;
        float: left !important;
        padding: 0 5px 0 0 !important;
        margin-top: 35px;
    }
    .link-preview .card-text {
        margin-top: 20px;
        padding-left: 15px;
    }
    .link-preview .card-footer {
        position: relative !important;
        margin-top: 70px;
    }
    .link-preview .card-body {
        padding: 1px 1px 1px 1px !important;
    }
    .link-preview .card-text {
        margin-top: 35px;
        padding-left: 15px;
    }
    
    

    The real issue with nodebb-plugin-link-preview is that it has no flexibility in terms of HTML layout meaning you have to get clever with CSS (and even then, it’s not clever at all).

    Using my OGProxy function, it would look like this by default

    https://community.nodebb.org/topic/17109/manual-build-a-night-mode-for-harmony

    However, because you have control over the HTML, you can simply rearrange it to suit your own needs.

  • phenomlabundefined phenomlab has marked this topic as solved
  • @phenomlab does OGProxy show the pdf previews as well?

  • @crazycells said in CSS code customization for the link preview plugin:

    does OGProxy show the pdf previews as well?

    Not yet, but it could with a bit of additional code.


Did this solution help you?
Did you find the suggested solution useful? Why not buy me a coffee? It's a nice gesture, and a great way to show your appreciation 💗

  • 1 Votes
    1 Posts
    278 Views
    No one has replied
  • Composer Zen icon?

    Solved Configure
    8
    2 Votes
    8 Posts
    211 Views

    @DownPW exactly. Not really a new concept, and in all honesty, not something I’ve ever used.

    If you consider the need to add links and references, or citations, you’d need to be able to see other parts of the screen!

  • hover link effect

    Solved Customisation
    18
    6 Votes
    18 Posts
    608 Views

    @DownPW Looking at the underlying code, class start is being added on hover by jQuery in this function

    document.querySelectorAll(".button-gradient, .button-transparent").forEach((button) => { const style = getComputedStyle(button); const lines = document.createElement("div"); lines.classList.add("lines"); const groupTop = document.createElement("div"); const groupBottom = document.createElement("div"); const svg = createSVG( button.offsetWidth, button.offsetHeight, parseInt(style.borderRadius, 10) ); groupTop.appendChild(svg); groupTop.appendChild(svg.cloneNode(true)); groupTop.appendChild(svg.cloneNode(true)); groupTop.appendChild(svg.cloneNode(true)); groupBottom.appendChild(svg.cloneNode(true)); groupBottom.appendChild(svg.cloneNode(true)); groupBottom.appendChild(svg.cloneNode(true)); groupBottom.appendChild(svg.cloneNode(true)); lines.appendChild(groupTop); lines.appendChild(groupBottom); button.appendChild(lines); button.addEventListener("pointerenter", () => { button.classList.add("start"); }); svg.addEventListener("animationend", () => { button.classList.remove("start"); }); }); })

    The CSS for start is below

    .button-gradient.start .lines svg, .button-transparent.start .lines svg { animation: stroke 0.3s linear; }

    And this is the corresponding keyframe

    @keyframes stroke { 30%, 55% { opacity: 1; } 100% { stroke-dashoffset: 5; opacity: 0; } }

    It’s using both CSS and SVG, so might not be a simple affair to replicate without the SVG files.

  • 3 Votes
    11 Posts
    708 Views

    @cagatay no problems

  • Quote design CSS

    Solved Customisation
    15
    4 Votes
    15 Posts
    684 Views

    @DownPW yes, that does make sense actually. I forgot to mention the layout of Sudonix is custom so that would have an impact on the positioning.

    Good spot 🙂

  • Link Text Colour.

    Solved Customisation
    5
    2 Votes
    5 Posts
    302 Views

    @phenomlab Thx again for the reply.

    Well I am sure that it will be well worth the wait. 🙂 I will watch with anticipation. For now it is OK. Just small minor irritations I fell in a lot of NodeBB ‘default’ things.

  • Error install plugin

    Solved Customisation
    8
    1 Votes
    8 Posts
    461 Views

    @pobojmoks

    Not WP plugin but nodeBB but it a known bug

  • 0 Votes
    7 Posts
    806 Views

    @RiekMedia hi. Just following up on this thread (I know it’s old) but was curious to understand if it’s still an issue or not ?