• Resolved Asome

    (@asome)


    Hi!
    How to make sure that all the pictures on the site can be opened using Lightbox?

    Previously, it was possible to set the “Media File” settings, and then the picture was enlarged on hover, but with the advent of Gutenberg this function disappeared somewhere – or I can’t find it.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Moderator James Huff

    (@macmanx)

    WordPress has never had lightbox functionality built-in.

    Perhaps it was provided by one of your plugins, or your theme at one time?

    There are a few plugins you can choose from for this: https://wordpress.org/plugins/search/lightbox/

    Thread Starter Asome

    (@asome)

    I know. I installed Responsive Lightbox but the pictures do not open.

    Moderator James Huff

    (@macmanx)

    In that case, I recommend reporting the problem at https://wordpress.org/support/plugin/responsive-lightbox-lite/ so the plugin’s developers and support community can help you with this.

    Thread Starter Asome

    (@asome)

    Thanks! But other Lightbox apps do not work. What needs to be done to open a picture using Lightbox? Maybe I forgot about some settings for each picture? I am using Gutenberg.

    Moderator James Huff

    (@macmanx)

    You’ll need to speak with support for the plugin you want to use.

    WordPress doesn’t provide lightbox functionality, so if something isn’t working with that, it would be up to the plugin.

    Thread Starter Asome

    (@asome)

    Thanks! I will try some more plugins.

    @macmanx Hi. I’m completely new here. Sorry for writing it here, but i search EVERYWHERE on how can i create new topic in this wordpress forum and i couldn’t find information. Please help me.

    Moderator James Huff

    (@macmanx)

    @kewlak Choose any forum, like https://wordpress.org/support/forum/how-to-and-troubleshooting/ and you’ll find a “Create Topic” button at the top.

    @macmanx Thank you. I went to Views -> All topics. That’s why i couldn’t find it there.

    • This reply was modified 6 years, 2 months ago by kewlak.
    Thread Starter Asome

    (@asome)

    I found a solution to the problem:

    ## делает IMG тег анкором ссылки на картинку указанную в этом теге, чтобы её можно было увеличить и посмотреть.
    add_filter( 'the_content', function( $content ){
    
      // пропускаем если в тексте нет картинок вообще...
      if( false === strpos( $content, '<img ') )
    	return $content;
    
      if( ! is_main_query() || ! in_array( $GLOBALS['post']->post_type, ['post'] ) )
    	return $content;
    
      $img_ex = '<img[^>]*src *= *["\']([^\'"]+)["\'][^>]*>';
      $content = preg_replace_callback( "~(?:<a[^>]+>\s*)$img_ex|($img_ex)~", function($mm){
    	// пропускаем, если картинка уже со ссылкой
    	if( empty($mm[2]) )
    	  return $mm[0];
    
    	return '<a href="'. $mm[3] .'">'. $mm[2] .'</a>';
      }, $content );
    
      return $content;
    }, 5 );

    Origin

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘Convert pictures to Lightbox’ is closed to new replies.