How to use "WOOF_Image :: save_image"

This topic is: not resolved

Tagged: 

Viewing 5 posts - 1 through 5 (of 5 total)
Author Posts
October 2, 2015 at 10:27 am #3694
aguko
Post count: 43

I would like to upload the image path inputted into the custom field to my server, and to use it as a thumbnail.

In that case, it is “WOOF_Image :: save_image” useful?

October 2, 2015 at 12:14 pm #3695
traversal
Post count: 207

Hi so just to clarify, you’ve already put an image URL into another field, but you want to use the image from that path as a thumbnail? I assume the other field is not an image type?

WOOF_Image::save_image is not really for this purpose, as this requires an image handle from the standard PHP way of loading in an image.

Where is your image stored? If it’s inside your theme folder, you could use this method to get an image relative to the top of the theme path:

https://www.masterpressplugin.com/docs/developer/methods/woof-theme-image

If it’s within wp-content, you could use the content_image method instead:

https://www.masterpressplugin.com/docs/developer/methods/woof-content-image

both of these will give you a WOOF_Image class which can then be used just like any image field, so you can call resize etc on the object.

October 2, 2015 at 5:13 pm #3696
aguko
Post count: 43

I am creating the list of the contents of an external site.

And I have inputted into the custom field (text field) the image set as OGP of each contents.

And I would like to upload the image path inputted at the time of preservation of a post to wp-content/uploads, and to use it as a thumbnail (Featured Image) of WordPress.

Since the post is imported by CSV, I cannot use URL download in the image field.

Can I use “WOOF_Image :: save_image” as how to download image URL inputted into the text field in such a situation?

Thanks.

October 6, 2015 at 10:19 am #3697
traversal
Post count: 207

Hey, save_image won’t help you here, as that is intended to load an existing image resource and save it out somewhere else.

I’m assuming you already have the image on the server inside wp-content/uploads, so you shouldn’t need to do that.

Are you trying to insert it into the core Feature Image field in WordPress? That would likely require you to insert an attachment to the post first, which is outlined here:

https://codex.wordpress.org/Function_Reference/wp_insert_attachment

You may also need to generate the metadata:
https://codex.wordpress.org/Function_Reference/wp_generate_attachment_metadata

And then you may also need to set the post meta to point to the new attachment ID:
https://wordpress.org/support/topic/how-to-programmatically-set-posts-featured-image

On the other hand if you’re using a MasterPress custom image field, you should be able to set the VALUE of that field to be the full URL to the image, and MasterPress should be able to see that image inside your wp-content/uploads directory.

So if you had “wp-content/uploads/car.jpg”, you could set the value of an image field to:

http://yoursiteurl.com/wp-content/uploads/car.jpg” and MasterPress should be able to recognise that image.

October 7, 2015 at 2:05 pm #3698
aguko
Post count: 43

I always thank exact support.

I try “wp_insert_attachment.”

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

Latest From the Blog

MasterPress 1.3.10 is now available

9th November 2023

MasterPress 1.3.10 is a feature and bugfix release. Workaround for fatal error introduced by changes to WordPress’ wpdb class in WordPress 6.4. Added actions to MPC files upload_field & WF image save_image functions.

Plugin Requirements

MasterPress requires a minimum of WordPress version 4.9, MySQL 5.6, and PHP version 5.6.20.

We also recommend that PHP is configured to use a memory limit of 64MB per request (128MB may be required for sites with higher complexity).

This plug-in is not compatible with the WordPress.com hosted service.

Three AM