iOS WP app: Featured image size problems

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

iOS WP app: Featured image size problems

Micky Hulse-3
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] => 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
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: iOS WP app: Featured image size problems

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.

On Oct 22, 2013, at 7:23 PM, Micky Hulse <[hidden email]> wrote:

> 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] => 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
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers

_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: iOS WP app: Featured image size problems

Simon Vart
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
---------------------

Le 23/10/2013 14:25, J.D. Grimes a écrit :

> 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.
>
> On Oct 22, 2013, at 7:23 PM, Micky Hulse <[hidden email]> wrote:
>
>> 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] => 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
>> [hidden email]
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
> _______________________________________________
> wp-hackers mailing list
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers

_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: iOS WP app: Featured image size problems

Micky Hulse-3
Hello,

Thanks so much for the replies J.D. and Simon, I really appreciate your help.

On Wed, Oct 23, 2013 at 5:25 AM, J.D. Grimes <[hidden email]> wrote:
> 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.

On Wed, Oct 23, 2013 at 7:57 AM, Simon Vart <[hidden email]> wrote:
> 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'

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
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: iOS WP app: Featured image size problems

Nikola Nikolov
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


On Wed, Oct 23, 2013 at 9:58 PM, Micky Hulse <[hidden email]>wrote:

> Hello,
>
> Thanks so much for the replies J.D. and Simon, I really appreciate your
> help.
>
> On Wed, Oct 23, 2013 at 5:25 AM, J.D. Grimes <[hidden email]> wrote:
> > 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.
>
> On Wed, Oct 23, 2013 at 7:57 AM, Simon Vart <[hidden email]>
> wrote:
> > 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'
>
> 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
> _______________________________________________
> wp-hackers mailing list
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: iOS WP app: Featured image size problems

Micky Hulse-3
Hi Nikola! Thank you for the quick reply and in-depth help. I greatly
appreciate it. :)

On Wed, Oct 23, 2013 at 12:39 PM, Nikola Nikolov <[hidden email]> wrote:
> 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
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: iOS WP app: Featured image size problems

Nicholas Ciske-2
In reply to this post by Micky Hulse-3
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

On Oct 23, 2013, at 1:58 PM, Micky Hulse wrote:

> Hello,
>
> Thanks so much for the replies J.D. and Simon, I really appreciate your help.
>
> On Wed, Oct 23, 2013 at 5:25 AM, J.D. Grimes <[hidden email]> wrote:
>> 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.
>
> On Wed, Oct 23, 2013 at 7:57 AM, Simon Vart <[hidden email]> wrote:
>> 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'
>
> 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
> _______________________________________________
> wp-hackers mailing list
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers

_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: iOS WP app: Featured image size problems

Micky Hulse-3
Hi Nicholas, thanks for the reply!

On Thu, Oct 24, 2013 at 5:06 AM, Nicholas Ciske <[hidden email]> wrote:
> 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
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers