frontend.php 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. global $content_width;
  3. $photo = $module->get_data();
  4. $classes = $module->get_classes();
  5. $src = $module->get_src();
  6. $link = $module->get_link();
  7. $alt = $module->get_alt();
  8. $attrs = $module->get_attributes();
  9. $filetype = pathinfo( $src, PATHINFO_EXTENSION );
  10. $rel = ( ! empty( $link ) && '_blank' == $settings->link_target ) ? ' rel="noopener"' : '';
  11. if ( isset( $photo->sizes ) && count( get_object_vars( $photo->sizes ) ) > 1 ) {
  12. if ( $settings->vamtam_sizes_attr !== 'default' ) {
  13. $global_settings = FLBuilderModel::get_global_settings();
  14. if ( $settings->vamtam_sizes_attr === 'custom' ) {
  15. $attrs .= ' sizes="' . esc_attr( $settings->vamtam_sizes_attr_custom ) . '"';
  16. } elseif ( $settings->vamtam_sizes_attr === 'beaver' ) {
  17. // walk up the parent tree to calculate the size of this module
  18. $parent_size = 100;
  19. $row_size = false;
  20. $parent = FLBuilderModel::get_node( $module->parent );
  21. while ( $parent ) {
  22. if ( $parent->type === 'column' ) {
  23. $parent_size *= (float) $parent->settings->size / 100;
  24. } elseif ( $parent->type === 'row' ) {
  25. if ( $parent->settings->width === 'full' && $parent->settings->content_width === 'full' ) {
  26. $row_size = 'full';
  27. } elseif ( $parent->settings->content_width === 'fixed' ) {
  28. $row_size = isset( $parent->settings->max_content_width ) && $parent->settings->max_content_width !== '' ? (int) $parent->settings->max_content_width : $content_width;
  29. }
  30. }
  31. $parent = FLBuilderModel::get_node( $parent->parent );
  32. }
  33. $parent_size = ceil( $parent_size );
  34. $row_limit = '';
  35. if ( $row_size !== 'full' ) {
  36. $row_limit = "(min-width: {$row_size}px) " . ( $row_size * $parent_size / 100 ) . "px,";
  37. }
  38. $attrs .= ' sizes="(max-width: ' . $global_settings->responsive_breakpoint . 'px) 100vw, ' . $row_limit . esc_attr( $parent_size ) . 'vw"';
  39. } else {
  40. $global_settings = FLBuilderModel::get_global_settings();
  41. $attrs .= ' sizes="(max-width: ' . $global_settings->responsive_breakpoint . 'px) 100vw, ' . esc_attr( $settings->vamtam_sizes_attr ) . '"';
  42. }
  43. }
  44. }
  45. ?>
  46. <div class="fl-photo<?php if ( ! empty( $settings->crop ) ) { echo ' fl-photo-crop-' . $settings->crop ;} ?> fl-photo-align-<?php echo $settings->align; ?>" itemscope itemtype="http://schema.org/ImageObject">
  47. <div class="fl-photo-content fl-photo-img-<?php echo $filetype; ?>">
  48. <?php if ( ! empty( $link ) ) : ?>
  49. <a href="<?php echo $link; ?>" target="<?php echo $settings->link_target; ?>"<?php echo $rel; ?> itemprop="url">
  50. <?php endif; ?>
  51. <?php if ( $settings->photo_source === 'library' && isset( $photo->width ) && isset( $photo->height ) ) : ?>
  52. <?php $classes .= ' vamtam-lazyload-noparent'; ?>
  53. <?php echo apply_filters( 'vamtam_maybe_lazyload', wp_make_content_images_responsive( '<img class="' . esc_attr( $classes ) . '" src="' . esc_attr( $src ) . '" alt="' . esc_attr( $alt ) . '" itemprop="image" ' . $attrs . '/>' ), $photo->id, array( $photo->width, $photo->height ), false ) ?>
  54. <?php else: ?>
  55. <img class="<?php echo esc_attr( $classes ) ?>" src="<?php echo esc_attr( $src ) ?>" alt="<?php echo esc_attr( $alt ) ?>" itemprop="image" <?php echo $attrs; ?> />
  56. <?php endif ?>
  57. <?php if ( ! empty( $link ) ) : ?>
  58. </a>
  59. <?php endif; ?>
  60. <?php if ( $photo && ! empty( $photo->caption ) && 'hover' == $settings->show_caption ) : ?>
  61. <div class="fl-photo-caption fl-photo-caption-hover" itemprop="caption"><?php echo $photo->caption; ?></div>
  62. <?php endif; ?>
  63. </div>
  64. <?php if ( $photo && ! empty( $photo->caption ) && 'below' == $settings->show_caption ) : ?>
  65. <div class="fl-photo-caption fl-photo-caption-below" itemprop="caption"><?php echo $photo->caption; ?></div>
  66. <?php endif; ?>
  67. </div>