Code Monkey home page Code Monkey logo

mybb-fancyboxthumbnails's Introduction

MyBB-FancyboxThumbnails

Small Fancybox Integration on MyBB 1.8.x

I was looking for someting like Fit on page for MyBB 1.8, but without good results. Build-in autoscaling is good, but not comfortable for me. I tried some code and find better solution. We can you Fancybox (or potential, any other similar JS library) to load images on demand in good-looking dialogs. Let's do this.

1. Edit theme CSS

Just edit your theme CSS and add this code:

.scaleimages img {
    max-width: 400px;
    max-height: 400px;
}

That 400 px is only an example. You should use best value for your board.

##2. Download Fancybox You must download Fancybox 3.0 from official site and upload files to your board root directory:

http://fancyapps.com/fancybox/3/

Let's say, that your index.php file is on /index.php.

You should move files from fancyBox-3.0/dist to /fancybox on your server (please create new directory).

##3. Add Fancybox to posts images Log in into board ACP and edit your theme headerinclude template. Add this code after {$stylesheets}:

<link rel="stylesheet" href="/fancybox/jquery.fancybox.min.css" type="text/css" media="screen" />
<script type="text/javascript" src="/fancybox/jquery.fancybox.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
    $('.post_body img').each(function() {
        var currentImage = $(this);
        
        if (currentImage.hasClass('smilie') == false && currentImage.parent().is('a') == false) {
            currentImage.wrap("<a target='_blank' data-fancybox data-type='image' href='" + currentImage.attr("src") + "'</a>");
        }
    });
});
</script>

This code will add links to all board images and enable Fancybox for them.

###4. Add Fancybox to thumbnails Log in into board ACP and edit your theme postbit_attachments_thumbnails_thumbnail template. Change:

<a href="attachment.php?aid={$attachment['aid']}"

to:

<a href="attachment.php?aid={$attachment['aid']}" data-fancybox="data-{$post['pid']}" data-type="image"

This code will enabled Fancybox for your thumbnails in posts. We use post ID to provide images grouping.

5. Optional: move Fancybox CSS

You don't have to use Fancybox CSS file from third point of that instruction. You can always copy Fancybox CSS code and add it to your theme CSS or add new stylesheet with that. It's nice solution, because you can modify that code quickly and directly from your ACP.

It's all!

It's all. Just save all templates and test Fancybox on your MyBB board!

mybb-fancyboxthumbnails's People

Contributors

lukasamd avatar

Watchers

 avatar  avatar

mybb-fancyboxthumbnails's Issues

Bug with this script

There may be a bug with this script I put it in and now my apache error log is being spammed with errors.

EG:
Its showing a missing file at "https: which I can tell isn't a valid path.
That thread PID listed is only images linked to imgur with this plugin.
https://community.cajgo-support.com/Thread-Multi-Platform-Final-Fantasy-XV?pid=126

[Wed Jun 06 21:59:48 2018] [error] [client 192.168.1.254] File does not exist: /home/cajgo-admin/domains/community/public_html/"https:, referer: https://community.cajgo-support.com/Thread-Multi-Platform-Final-Fantasy-XV?pid=126

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.