kylereicks / picturefill.js.wp

A WordPress plugin to use Picturefill.js for image loading.
106 stars 10 forks source link

Picturefillwp 2 weird srcset URLs #37

Closed inbetweencode closed 10 years ago

inbetweencode commented 10 years ago

Outputted html srcset=" http://site.com/wp-content/uploads/filenam/filenameofpicture-360x240.png 360w, http://site.com/wp-content/uploads/filenam/filenameofpicture-720x480.png 720w, http://site.com/wp-content/uploads/filenam/filenameofpicture-1080x720.png 1080w, http://site.com/wp-content/uploads/filenam/ofpicture.png 1500w "

My media files are actually directly in the /uploads folder.

Has it something to do with: private function set_image_attachment_data() in class-model-image-picturefill-wp.php

... $this->upload_subdir = '/' . substr($image_attachment_metadata['file'], 0, 7); ... $image_attachment_data['full'] = array( 'file' => substr($image_attachment_metadata['file'], 8), ... $image_attachment_data[$image_size]['url'] = $this->application_model->get_upload_base_url() . $this->upload_subdir . '/' . $image_data['file'];

kylereicks commented 10 years ago

Thanks for the feedback @kleine-jean. If I understand the issue correctly, we're dealing with an image file that is not in the default year/month/file structure. You are right in pointing out that the plugin was not prepared for this. Commit e64c32650b3533f6efe38e84eb8e0a25a054e606 should account for a more diverse set of file structures. I'm afraid I didn't take the time to duplicate the circumstances of the issue, so if it reoccurs despite the fix, please let me know.

Thanks very much

inbetweencode commented 10 years ago

a problem still occurs with the full/original image; 8 character are stripped from the filename.

srcset=" http://site.com/wp-content/uploads/filenameofpicture-360x540.png 360w, http://site.com/wp-content/uploads/ofpicture.png 1000w" src="http://site.com/wp-content/uploads/ofpicture.png"

... 'file' => substr($image_attachment_metadata['file'], 8) ...

Thank you very much for writing this Picturefill 2 WP plugin I was about to write myself.

kylereicks commented 10 years ago

Well spotted, I missed the full-size image.