Skip to content

Commit

Permalink
Changes captions info so that it persists properly. Bumping version a…
Browse files Browse the repository at this point in the history
…nd screenshot.
  • Loading branch information
padams committed Aug 16, 2020
1 parent 0202bcf commit 7153613
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 26 deletions.
Binary file modified .wordpress-org/screenshot-1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ License: GPLv3
License URI: http://www.gnu.org/licenses/gpl.html
Requires at least: 5.2.0
Tested up to: 5.5
Stable tag: 1.2.8
Stable tag: 1.2.9

Making WordPress work for photographers with beautiful image galleries, slideshows, meta-data tools, and more.

Expand Down
3 changes: 3 additions & 0 deletions modules/metadata/metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,13 @@ function addAttributesToImages( $attr, $attachment = null ) {

//$attachment = get_post( $attachment_id );
$attachment_title = wptexturize( $attachment->post_title );
$attachment_caption = wptexturize( $attachment->post_excerpt );
$attachment_desc = wpautop( wptexturize( $attachment->post_content ) );
//$size = isset( $meta['width'] ) ? intval( $meta['width'] ) . ',' . intval( $meta['height'] ) : '';
$attr['data-orig-file'] = esc_attr( $orig_file );
//$attr['data-orig-size'] = $size;
// no longer needed as Gallery block sets this
//$attr['data-image-caption'] = esc_attr( htmlspecialchars( $attachment_caption ) );
$attr['data-image-title'] = esc_attr( htmlspecialchars( $attachment_title ) );
$attr['data-image-description'] = esc_attr( htmlspecialchars( $attachment_desc ) );
$attr['srcset'] = wp_get_attachment_image_srcset( $attachment_id );
Expand Down
9 changes: 1 addition & 8 deletions modules/slideshow/assets/js/slideshow.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,14 +396,7 @@ photopress.slideshow.prototype = {

getCaptionFromGalleryItem: function( id ) {

var that = this;

let caption = jQuery( that.getOption( 'gallerySelector' ) + ' .photopress-gallery-item[data-id=' + id + ']').find('figcaption').html();

if ( typeof caption !== 'undefined' && caption !== '' && caption !== null && caption.length > 0 ) {

return caption;
}
return this.getDataFromGalleryItem( id, 'caption' );
},

getDataFromGalleryItem: function( id, key ) {
Expand Down
4 changes: 2 additions & 2 deletions photopress.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Author: Peter Adams
Author URI: http://www.photopressdev.com
License: GPL v3
Version: 1.2.8
Version: 1.2.9
*/

// If this file is called directly, abort.
Expand Down Expand Up @@ -77,7 +77,7 @@ public static function getInstance() {
array(
'package_name' => 'core',
'package_label' => 'PhotoPress',
'version' => '1.2.8',
'version' => '1.2.9',
'modules' => ['base', 'childpages', 'gallery', 'slideshow', 'metadata'],
'dependencies' => []
)
Expand Down
5 changes: 3 additions & 2 deletions src/blocks/gallery/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@
},
"caption": {
"type": "string",
"source": "html",
"selector": ".photopress-gallery-item__caption"
"source": "attribute",
"selector": "img",
"attribute": "data-caption"
},
"title": {
"type": "string",
Expand Down
10 changes: 3 additions & 7 deletions src/blocks/gallery/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ class GalleryEdit extends Component {
// newImage.id to a string.
const newImageId = toString( newImage.id );
const currentImage = find( images, { id: newImageId } );

const currentImageCaption = currentImage
? currentImage.caption
: newImage.caption;
Expand Down Expand Up @@ -215,8 +214,6 @@ class GalleryEdit extends Component {

} );



this.setAttributes( {
images: newImages.map( ( newImage ) => ( {

Expand All @@ -230,9 +227,9 @@ class GalleryEdit extends Component {
// block is parsed it's converted to a string. Converting
// to a string here ensures it's type is consistent.
id: toString( newImage.id ),
//aspectRatio: this.calcAspectRatio(newImage),
apsectRatio: newImage.aspectRatio,
title: ''
// adding aspec ratio
apsectRatio: newImage.aspectRatio

} ) ),
columns: columns ? Math.min( newImages.length, columns ) : columns,
} );
Expand Down Expand Up @@ -339,7 +336,6 @@ class GalleryEdit extends Component {
galleryStyle,
themeHorizontalMargin
} = attributes;


const hasImages = !! images.length;

Expand Down
7 changes: 3 additions & 4 deletions src/blocks/gallery/gallery-masonry.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ class MasonryGallery extends Component {
gutter,
gutterMobile
} = attributes;



const masonryOptions = {

columnWidth: '.grid-sizer',
Expand Down Expand Up @@ -100,14 +99,14 @@ class MasonryGallery extends Component {
></li>

{ images.map( ( img, index ) => {

const ariaLabel = sprintf(
/* translators: 1: the order number of the image. 2: the total number of images. */
__( 'image %1$d of %2$d in gallery' ),
index + 1,
images.length
);
//console.log(img);

return (

<li
Expand Down
4 changes: 2 additions & 2 deletions src/blocks/gallery/save.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,19 +225,19 @@ export default function save( { attributes } ) {
<img
src={ image.url }
alt={ image.alt }
data-caption={image.caption}
data-id={ image.id }
data-aspectRatio={image.aspectRatio}
data-position={index}
data-full-url={ image.fullUrl }
data-link={ image.link }
className={ image.id ? `wp-image wp-image-${ image.id }` : null }
//sizes={`(max-width: 700px) 100vw, calc( ${sizesAttrCalc} )`}
sizes={'(max-width: 700px) 100vw, calc(' + getImageSizeCalc( image.aspectRatio ) +')'}
width={ getImageDimensions( image.aspectRatio ).width }
height={ getImageDimensions( image.aspectRatio ).height }
/>
);

return (
<li
key={ image.id || image.url }
Expand Down

0 comments on commit 7153613

Please sign in to comment.