Discussion:
iOS WP app: Featured image size problems
Micky Hulse
2013-10-22 23:23:16 UTC
Permalink
Hi,

Details: Wordpress 3.6.1, iOS WP app 3.8.3.

I'm hoping someone can help me figure this one out. I can't seem to
find an answer on Google.

Scenario:

Create/publish post from the WP iOS app that has a featured image
(uploaded as "original" size).

Problem:

Functions that get the post's thumbnail only return original size.

What I see:

When looking at FTP upload location, all of the image sizes (I've got
several custom sizes) are there.

When I run:

print_r(wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), '300px'));

... I get:

Array
(
[0] => Loading Image...
[1] => 0
[2] => 0
[3] =>
)

I'm not sure how to trouble shoot this.

At first I thought that maybe the WP app did not obey the custom
images sizes ... But they are generated and sitting there in my
uploads folder.

It's almost like something, image related, isn't getting logged to the
database when the WP app makes a post.

I'd love some help. I'm hoping it's something I overlooked and is easy
to fix. :)

Thanks!
M
J.D. Grimes
2013-10-23 12:25:43 UTC
Permalink
I don't think that wp_get_attachment_image_src() accepts parameters of the format you are using ('300px'). http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src

The $size can either be a keyword (thumbnail, medium, large or full) or an array (array(300,300)).

-J.D.
Post by Micky Hulse
Hi,
Details: Wordpress 3.6.1, iOS WP app 3.8.3.
I'm hoping someone can help me figure this one out. I can't seem to
find an answer on Google.
Create/publish post from the WP iOS app that has a featured image
(uploaded as "original" size).
Functions that get the post's thumbnail only return original size.
When looking at FTP upload location, all of the image sizes (I've got
several custom sizes) are there.
print_r(wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), '300px'));
Array
(
[0] => http://foo.com/blog/files/2013/10/20131022-160759.jpg
[1] => 0
[2] => 0
[3] =>
)
I'm not sure how to trouble shoot this.
At first I thought that maybe the WP app did not obey the custom
images sizes ... But they are generated and sitting there in my
uploads folder.
It's almost like something, image related, isn't getting logged to the
database when the WP app makes a post.
I'd love some help. I'm hoping it's something I overlooked and is easy
to fix. :)
Thanks!
M
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
Simon Vart
2013-10-23 14:57:35 UTC
Permalink
I think you could also add a new image size in functions.php :

add_image_size( '300px', 300, 300, true );

and then your call to wp_get_attachment_image_src() will be understood.
When you upload an image, WP will create a image of this size with the
keyword '300px'
--
---------------------
Simon Vart
développement web / informatique
----
02.98.67.92.70
06.09.97.82.91
www.exigences.biz
linkedin : http://www.linkedin.com/profile/view?id=87258047
twitter : @simonvart
skype: carantecinfo
---------------------
Post by J.D. Grimes
I don't think that wp_get_attachment_image_src() accepts parameters of the format you are using ('300px'). http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src
The $size can either be a keyword (thumbnail, medium, large or full) or an array (array(300,300)).
-J.D.
Post by Micky Hulse
Hi,
Details: Wordpress 3.6.1, iOS WP app 3.8.3.
I'm hoping someone can help me figure this one out. I can't seem to
find an answer on Google.
Create/publish post from the WP iOS app that has a featured image
(uploaded as "original" size).
Functions that get the post's thumbnail only return original size.
When looking at FTP upload location, all of the image sizes (I've got
several custom sizes) are there.
print_r(wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), '300px'));
Array
(
[0] => http://foo.com/blog/files/2013/10/20131022-160759.jpg
[1] => 0
[2] => 0
[3] =>
)
I'm not sure how to trouble shoot this.
At first I thought that maybe the WP app did not obey the custom
images sizes ... But they are generated and sitting there in my
uploads folder.
It's almost like something, image related, isn't getting logged to the
database when the WP app makes a post.
I'd love some help. I'm hoping it's something I overlooked and is easy
to fix. :)
Thanks!
M
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
Micky Hulse
2013-10-23 18:58:23 UTC
Permalink
Hello,

Thanks so much for the replies J.D. and Simon, I really appreciate your help.
Post by J.D. Grimes
I don't think that wp_get_attachment_image_src() accepts parameters of the format you are using ('300px'). http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src
The $size can either be a keyword (thumbnail, medium, large or full) or an array (array(300,300)).
My bad. I apologize that I did not mention the rest of my setup.

In my functions file, I have:

function mytheme_setup() {
add_theme_support('post-thumbnails');
set_post_thumbnail_size(150, 150);
}
add_action('after_setup_theme', 'mytheme_setup');
// ... and later on in this file:
# Add new image sizes:
add_image_size('130px', 130); // Thumbnail size: 130 x 130
add_image_size('300px', 300); // Medium size: 300 x 300
add_image_size('470px', 470);
add_image_size('640px', 640);
add_image_size('810px', 810);
add_image_size('980px', 980); // Large size: 980 x 980
add_image_size('1320px', 1320);
add_image_size('1620px', 1620);
add_image_size('1960px', 1960);

The new image size names are based on another system we use ... I
wanted to keep the "XXXpx" naming conventions the same across systems.

With that said, the use of (for example):

wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), '300px')
wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), '640px')

... work for all images, except for images uploaded as a featured
image using the WP iOS app.

Other image getting functions also work, but it's the iOS images that
just return the original source image size.
Post by J.D. Grimes
add_image_size( '300px', 300, 300, true );
and then your call to wp_get_attachment_image_src() will be understood. When
you upload an image, WP will create a image of this size with the keyword
'300px'
Sorry again, that I did not detail my setup. Thank you for the help,
and thankfully I do have that setup in my functions.php file. I
should've made that clear in my first message. :(

Question(s):

When you folks use the iOS WP app, and set a featured image, are you
able to get at the different sizes on your templates?

For some reason, my setup isn't allowing me to access the custom image
sizes (only for iOS-uploaded featured images), even though they are
generated and sitting there in my uploads folder.

Maybe I'm not setup properly in my functions.php file? I have all of
my add_image_size() calls just sitting out in the open. Do I need to
have these inside of an action? Should they go inside the
"after_setup_theme" action along side my
add_theme_support('post-thumbnails') call?

Please let me know if I can provide more information.

Thank you!

M
Nikola Nikolov
2013-10-23 19:39:13 UTC
Permalink
Can you try doing

print_r( wp_get_attachment_metadata( get_post_thumbnail_id( $post->ID ) ) );

And see what the "sizes" key of the returned array contains? In theory all
of your custom sizes data should be right there(see the function in the
codex -
http://codex.wordpress.org/Function_Reference/wp_get_attachment_metadata ).

If there are no sizes(or only the default ones are there), try the
following:

$uploads_dir = wp_upload_dir();
$thumbnail_id = get_post_thumbnail_id( $post->ID );
$file_name = wp_get_attachment_metadata( $thumbnail_id );
$file_name = $file_name && isset( $file_name['file'] ) ? $file_name['file']
: false;
if ( $file_name ) {
include_once( ABSPATH . 'wp-admin/includes/image.php' );
echo "Generating attachment metadata for attachment with ID {$
thumbnail_id}:\n";
print_r( wp_generate_attachment_metadata( $thumbnail_id, $file_name ) );
} else {
echo 'No file found';
}

This should in theory generate the attachment metadata - if you have your
sizes in the "sizes" array key, then the problem is either in your
set-up(theme/plugins), or the iOS app.

To investigate further, set-up a default install(no plugins, the default
theme - maybe add in a custom size in there) and use the iOS app to upload
a featured image for a post. Then see if the Featured image comes in your
size - if it does, then it's either your theme, or one of your plugins. If
it doesn't - it's a bug in the iOS app which you should file here -
https://github.com/wordpress-mobile/WordPress-iOS/issues

I hope some of that helps,
Nikola
Post by Micky Hulse
Hello,
Thanks so much for the replies J.D. and Simon, I really appreciate your help.
Post by J.D. Grimes
I don't think that wp_get_attachment_image_src() accepts parameters of
the format you are using ('300px').
http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src
Post by J.D. Grimes
The $size can either be a keyword (thumbnail, medium, large or full) or
an array (array(300,300)).
My bad. I apologize that I did not mention the rest of my setup.
function mytheme_setup() {
add_theme_support('post-thumbnails');
set_post_thumbnail_size(150, 150);
}
add_action('after_setup_theme', 'mytheme_setup');
add_image_size('130px', 130); // Thumbnail size: 130 x 130
add_image_size('300px', 300); // Medium size: 300 x 300
add_image_size('470px', 470);
add_image_size('640px', 640);
add_image_size('810px', 810);
add_image_size('980px', 980); // Large size: 980 x 980
add_image_size('1320px', 1320);
add_image_size('1620px', 1620);
add_image_size('1960px', 1960);
The new image size names are based on another system we use ... I
wanted to keep the "XXXpx" naming conventions the same across systems.
wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), '300px')
wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), '640px')
... work for all images, except for images uploaded as a featured
image using the WP iOS app.
Other image getting functions also work, but it's the iOS images that
just return the original source image size.
Post by J.D. Grimes
add_image_size( '300px', 300, 300, true );
and then your call to wp_get_attachment_image_src() will be understood.
When
Post by J.D. Grimes
you upload an image, WP will create a image of this size with the keyword
'300px'
Sorry again, that I did not detail my setup. Thank you for the help,
and thankfully I do have that setup in my functions.php file. I
should've made that clear in my first message. :(
When you folks use the iOS WP app, and set a featured image, are you
able to get at the different sizes on your templates?
For some reason, my setup isn't allowing me to access the custom image
sizes (only for iOS-uploaded featured images), even though they are
generated and sitting there in my uploads folder.
Maybe I'm not setup properly in my functions.php file? I have all of
my add_image_size() calls just sitting out in the open. Do I need to
have these inside of an action? Should they go inside the
"after_setup_theme" action along side my
add_theme_support('post-thumbnails') call?
Please let me know if I can provide more information.
Thank you!
M
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
Micky Hulse
2013-10-23 19:50:38 UTC
Permalink
Hi Nikola! Thank you for the quick reply and in-depth help. I greatly
appreciate it. :)
Post by Nikola Nikolov
I hope some of that helps,
Very much so!

I will follow your tests today and report back my findings. I'm
guessing it's my theme (the only plugins I'm running are "New blog
defaults" and a simple MU plugin for subheads).

With that said, most of the code used other than plugins is all mine,
so there's a high possibility that I introduced a bug somewhere along
the process of building a theme from ground up.

Thanks again! I'll be back with my findings.

Cheers,
Micky
Nicholas Ciske
2013-10-24 12:06:07 UTC
Permalink
Not a true solution, but a viable workaround: you could install WP Thumb which will create missing image sizes on the fly (and then cache them for future use).

http://wordpress.org/plugins/wp-thumb/

_________________________
Nick Ciske
http://thoughtrefinery.com/
@nciske
Post by Micky Hulse
Hello,
Thanks so much for the replies J.D. and Simon, I really appreciate your help.
Post by J.D. Grimes
I don't think that wp_get_attachment_image_src() accepts parameters of the format you are using ('300px'). http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src
The $size can either be a keyword (thumbnail, medium, large or full) or an array (array(300,300)).
My bad. I apologize that I did not mention the rest of my setup.
function mytheme_setup() {
add_theme_support('post-thumbnails');
set_post_thumbnail_size(150, 150);
}
add_action('after_setup_theme', 'mytheme_setup');
add_image_size('130px', 130); // Thumbnail size: 130 x 130
add_image_size('300px', 300); // Medium size: 300 x 300
add_image_size('470px', 470);
add_image_size('640px', 640);
add_image_size('810px', 810);
add_image_size('980px', 980); // Large size: 980 x 980
add_image_size('1320px', 1320);
add_image_size('1620px', 1620);
add_image_size('1960px', 1960);
The new image size names are based on another system we use ... I
wanted to keep the "XXXpx" naming conventions the same across systems.
wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), '300px')
wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), '640px')
... work for all images, except for images uploaded as a featured
image using the WP iOS app.
Other image getting functions also work, but it's the iOS images that
just return the original source image size.
Post by J.D. Grimes
add_image_size( '300px', 300, 300, true );
and then your call to wp_get_attachment_image_src() will be understood. When
you upload an image, WP will create a image of this size with the keyword
'300px'
Sorry again, that I did not detail my setup. Thank you for the help,
and thankfully I do have that setup in my functions.php file. I
should've made that clear in my first message. :(
When you folks use the iOS WP app, and set a featured image, are you
able to get at the different sizes on your templates?
For some reason, my setup isn't allowing me to access the custom image
sizes (only for iOS-uploaded featured images), even though they are
generated and sitting there in my uploads folder.
Maybe I'm not setup properly in my functions.php file? I have all of
my add_image_size() calls just sitting out in the open. Do I need to
have these inside of an action? Should they go inside the
"after_setup_theme" action along side my
add_theme_support('post-thumbnails') call?
Please let me know if I can provide more information.
Thank you!
M
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
Micky Hulse
2013-10-24 18:23:47 UTC
Permalink
Hi Nicholas, thanks for the reply!
Post by Nicholas Ciske
Not a true solution, but a viable workaround: you could install WP Thumb which will create missing image sizes on the fly (and then cache them for future use).
http://wordpress.org/plugins/wp-thumb/
That's actually an approach I'm familiar with. :)

Back when I used EE, that's how we handled images. I do the same thing
for Django apps. It's kinda nice having the freedom to resize images
on the template level.

I still have yet to test Nikola's suggestions, but I'm hoping to get
to that today as I would like to know if there's something setup wrong
with my theme.

Anyway, I'll give wp-thumb a go. Thanks for tip!

Have a nice day.

Cheers,
Micky

Continue reading on narkive:
Search results for 'iOS WP app: Featured image size problems' (Questions and Answers)
3
replies
HTC One silver or Lumia 920 yellow?
started 2013-02-23 13:35:53 UTC
cell phones & plans
Loading...