Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix additional image sizes paths #622

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

neojp
Copy link

@neojp neojp commented Feb 20, 2023

When trying to update the ACL on my images, I noticed the thumbnails weren't getting updated. While going through the rabbit hole I noticed the S3 batch commands were sending the following keys:

array (size=5)
  0 => string 's3://bucket-name/uploads/2023/02/unsplash_waxDxYM2XI4.jpg' (length=63)
  1 => string 's3://bucket-name/uploadsunsplash_waxDxYM2XI4-300x223.jpg' (length=62)
  2 => string 's3://bucket-name/uploadsunsplash_waxDxYM2XI4-1024x760.jpg' (length=63)
  3 => string 's3://bucket-name/uploadsunsplash_waxDxYM2XI4-150x150.jpg' (length=62)
  4 => string 's3://bucket-name/uploadsunsplash_waxDxYM2XI4-768x570.jpg' (length=62)

And they should be like this:

array (size=5)
  0 => string 's3://bucket-name/uploads/2023/02/unsplash_waxDxYM2XI4.jpg' (length=63)
  1 => string 's3://bucket-name/uploads/2023/02/unsplash_waxDxYM2XI4-300x223.jpg' (length=71)
  2 => string 's3://bucket-name/uploads/2023/02/unsplash_waxDxYM2XI4-1024x760.jpg' (length=72)
  3 => string 's3://bucket-name/uploads/2023/02/unsplash_waxDxYM2XI4-150x150.jpg' (length=71)
  4 => string 's3://bucket-name/uploads/2023/02/unsplash_waxDxYM2XI4-768x570.jpg' (length=71)

Copy link
Member

@joehoyle joehoyle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thankss @neojp! I think we never ran into this as we use Tachyon for image downsizing from the original in our stack.

@@ -551,7 +551,7 @@ public static function get_attachment_files( int $attachment_id ) : array {
$meta = wp_get_attachment_metadata( $attachment_id );
if ( isset( $meta['sizes'] ) ) {
foreach ( $meta['sizes'] as $size => $sizeinfo ) {
$files[] = $uploadpath['basedir'] . $sizeinfo['file'];
$files[] = $uploadpath['path'] . '/' . $sizeinfo['file'];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm path will return the current month directory. I guess I had thought that $sizeinfo['file'] was a relative path to the basedir, but that doesn't seem to be the case. I think it might need to be something like basedir( $main_file ) . '/' . $sizeinfo['file']?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You were right, I definitely noticed the dates not matching after a while. I had to change the code a bit, but haven't had a chance revisit this ticket yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants