Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Arno Welzel

    (@awelzel)

    What you you expect, when you add a data-author attribute?

    If you need a caption you have to add this in the WordPress media properties as description.

    Thread Starter woovn

    (@woovn)

    Caption can’t go down the line. data-author is required to get it down.

    demo

    This is my code:

     <a href="<?php echo $image['url']; ?>" data-author="<?php the_field('photo', 'option'); ?>">
    <img src="<?php echo $image['sizes']['thumbnail']; ?>" alt="<?php echo $image['alt']; ?>" />
    </a>
    <figcaption itemprop="caption description"><?php echo $image['alt']; ?></figcaption>
    
    • This reply was modified 5 years, 5 months ago by woovn.
    • This reply was modified 5 years, 5 months ago by woovn.
    Plugin Author Arno Welzel

    (@awelzel)

    Image captions can be multiline in WordPress as well and you can also add HTML code

    See for example:
    https://wordpress-demo.arnowelzel.de/lightbox-with-photoswipe/#&gid=1&pid=13

    But if I understand you correctly, you don’t want to have the author info in the page itself but only in the lightbox view?

    Thread Starter woovn

    (@woovn)

     <a href="<?php echo $image['url']; ?>" data-caption="<?php echo $image['alt']; ?><br>
         <?php the_field('photo', 'option'); ?>"><img src="<?php echo $image['sizes']['thumbnail']; ?>" alt="<?php echo $image['alt']; ?>" /></a>

    It does not work

    Plugin Author Arno Welzel

    (@awelzel)

    You have to escape the output by using htmlspecialchars():

    <a href="<?php echo $image['url']; ?>" data-caption="<?php echo htmlspecialchars($image['alt'].'<br>'.the_field('photo', 'option')); ?>"><img src="<?php echo $image['sizes']['thumbnail']; ?>" alt="<?php echo $image['alt']; ?>" /></a>

    Also see the source of https://wordpress-demo.arnowelzel.de/lightbox-with-photoswipe/ (I cant show it here, since the comment system would automatically convert escaped entities).

    • This reply was modified 5 years, 4 months ago by Arno Welzel. Reason: Escaped HTML entities can't be shown
    Thread Starter woovn

    (@woovn)

    <a href="<?php echo $image['url']; ?>" data-caption="<?php echo htmlspecialchars($image['alt'].'<br><small>Photo: '.the_field('photo', 'option').'</small>'); ?>">
           <img src="<?php echo $image['sizes']['thumbnail']; ?>" alt="<?php echo $image['alt']; ?>" /></a>

    I tried but it was still wrong

    Plugin Author Arno Welzel

    (@awelzel)

    Then I don’t know what to do. See the example I told you. There the caption just works fine:

    https://wordpress-demo.arnowelzel.de/lightbox-with-photoswipe/

    And the single image with the caption:

    https://wordpress-demo.arnowelzel.de/lightbox-with-photoswipe/#&gid=1&pid=13

    See the source of the page – it’s exactly as I told you.

    So if it does not work for you, you have a problem with your site which has nothing to do with Lightbox with Photoswipe.

    • This reply was modified 5 years, 4 months ago by Arno Welzel.
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Data-author does not work’ is closed to new replies.