Tagged: save_image
- This topic has 4 replies, 2 voices, and was last updated 9 years, 1 month ago by aguko.
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: And then you may also need to set the post meta to point to the new attachment ID: 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.” |
You must be logged in to reply to this topic.