• Resolved alex80ks

    (@alex80ks)


    I have some weird problem so i wanted to ask maybe someone can help me.
    Buddypress activity stream on my page here looks ok and images are shown ok but when i press Read more on some article there on that page, content of the article gets expanded as it should be but when i click on image from that article fancybox effect doesnt work just for that article.
    Does somebody have same problem?

    https://wordpress.org/plugins/easy-fancybox/

Viewing 15 replies - 1 through 15 (of 16 total)
  • Thread Starter alex80ks

    (@alex80ks)

    I found out this
    this is the code of element before i press Read more

    <div id="attachment_3120" class="wp-caption alignleft" style="width: 160px">
    <a class="fancybox" rel="gallery" href="http://www.xxx.com/wp-content/uploads/2014/07/iphone-6.jpg">
    <img class="size-thumbnail wp-image-3120" width="150" height="150" alt="Ajfon 6" src="http://www.xxx.com/wp-content/uploads/2014/07/iphone-6-150x150.jpg">
    </a>
    <p class="wp-caption-text">Ajfon 6</p>
    </div>

    and this is after i click Read more on Activity stream

    <div id="attachment_3120" class="wp-caption alignleft" style="width: 160px">
    <a rel="nofollow" href="http://www.xxx.com/wp-content/uploads/2014/07/iphone-6.jpg">
    <img class="size-thumbnail wp-image-3120" width="150" height="150" alt="Ajfon 6" src="http://www.xxx.com/wp-content/uploads/2014/07/iphone-6-150x150.jpg">
    </a>
    <p class="wp-caption-text">Ajfon 6</p>
    </div>

    It is missing fancybox class after clicking Read more.
    Does anybody have same problem?
    Thanks

    Hi alex80ks, the problem here is new content being loaded via Ajax. For FancyBox to ‘know’ which links it should bind itself to, it needs an event trigger. The plugin uses currenty two events: “document ready” which happens right at page load, and “post-load” which is an event fired by Jetpack Infinite Scroll after loading new posts via ajax on scrolling down a category page for example…

    I’m surprised that BuddyPress does not use the same “post-load” event. If you can find out if BuddyPress fires an event at all and what its handle/name is, then I can update Easy FancyBox to start listening for this event too.

    Thread Starter alex80ks

    (@alex80ks)

    Thanks for reply Ravan. I posted this on buddypress.org but havent get response. Can i give you acces to my site to take a look?
    Of course if you have time or will 🙂

    I’ve looked at your site and I think I found the script code where this stuff is done. It’s inside the global.js script in the default BP theme. And there might be a way to make it work by modifying a little snippet inside wp-content/plugins/buddypress/bp-themes/bp-default/_inc/global.js …

    Open that file in the WP theme editor and find about 1/5th to 1/4th down the content:

    // Activity "Read More" links
    	jq('div.activity').on('click', '.activity-read-more a', function(event) {
    		var target = jq(event.target);
    		var link_id = target.parent().attr('id').split('-');
    		var a_id = link_id[3];
    		var type = link_id[0]; /* activity or acomment */
    
    		var inner_class = type == 'acomment' ? 'acomment-content' : 'activity-inner';
    		var a_inner = jq('li#' + type + '-' + a_id + ' .' + inner_class + ':first' );
    		jq(target).addClass('loading');
    
    		jq.post( ajaxurl, {
    			action: 'get_single_activity_content',
    			'activity_id': a_id
    		},
    		function(response) {
    			jq(a_inner).slideUp(300).html(response).slideDown(300);
    		});
    
    		return false;
    	});

    Now append (before the closing ; character!) a .trigger('post-load') to the line inside the function(response) { ... } so that it looks like:

    jq(a_inner).slideUp(300).html(response).slideDown(300).trigger('post-load');

    Let me know if that does the trick or not 🙂

    Thread Starter alex80ks

    (@alex80ks)

    Thank you very much. You saved me 🙂 this is working really good.
    I have one more question to ask if you have couple of minuts.

    I hope you liked way of using your plugin especially home page inside of cube menu.

    Good to hear. Be aware that when you update the theme, your change will be lost… Maybe you can suggest it on your buddypress.org forum post as a permanent solution 🙂

    I hope you liked way of using your plugin especially home page inside of cube menu.

    Sure 🙂 one tip: take a look at the plugin http://wordpress.org/plugins/show-content-only/ which you can use it in combination with these iframe links so that only the content will be shown, not the header and sidebars.

    Thread Starter alex80ks

    (@alex80ks)

    Thanks for the tip. I have leave that way because it can be boring to close each time iframe. So i leave it as it is with all elements so the user can navigate without closing iframe. Do you think is it bad for something?
    i will try to suggest change but i dont know will they accept it.

    Question that i wanted to ask probably isnt connected with your plugin but it is better to ask and eliminate that possibility.

    here is the article for example. when i set featured image it is looks like right now. If i remove featured image i get normal look.
    problem is #header background-image.Some weird way header “pick-up” featured image as background. it doesnt happens all the time but it happens.

    Did you run onto it sometimes?

    Also i can suggest one more feature for your plugin if you want.

    Thank you for you help once more 🙂

    Do you think is it bad for something?

    No no, not bad. It’s just a choice 🙂

    problem is #header background-image.Some weird way header “pick-up” featured image as background. it doesnt happens all the time but it happens.

    Sounds like that is part of how the theme does featured images. It’s the same with Twenty Eleven for example… To make it look better, I’d remove the rule #header #search-bar .padder {height: auto;padding: 0 15px 50px 20px;} from wp-content/themes/bp_vs/style.css but if you want to disable that featured image to header image thing all together, then you’ll need to get help on the buddypress forum I think.

    Thread Starter alex80ks

    (@alex80ks)

    Thank you for your help i will try it.

    Thread Starter alex80ks

    (@alex80ks)

    Im osrry for being annoying but i run into one more problem. Activity stream on my website is ok but when i scroll down, at end of the page there is Load more button for older posts, when i click it it expands content but when i click on images below that button fancybox doesnt show it as it should.

    Should i search again same file and try to use same method as you write at beginning of this thread?

    Thank you 🙂

    Hi, yes this is a similar case… Look in the same global.js file for the part that starts with

    /* Load more updates at the end of the page */

    and then try adding .trigger('post-load') to jq("#content ul.activity-list").append(response.contents) (before the closing ; character!) inside the function(resonse) there.

    Thread Starter alex80ks

    (@alex80ks)

    I added that but weird things happens. when i click Load more it expands then if i click image it doesnt work, but if i click first read more and then i click on same image or any image below then it is all ok.

    Thread Starter alex80ks

    (@alex80ks)

    Buddypress team will make changes for Read More solution. I get notified few hours ago.

    Thread Starter alex80ks

    (@alex80ks)

    Im sorry this solution is working. My bad. I havent updated cdn with changed file so that is why didnt worked.

    Now it is working like a charm. I made pastebin code for buddypress developers to inspect and to add in next release.

    Thank you very much for your help.

    Thanks for testing and sharing Alex 🙂

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Easy fancybox with buddypress’ is closed to new replies.