Inserting images as featured image on custom poste

Closed

Import WP Addon - Advanced Custom Fields Updated 5 months ago 5 Replies

amor asked 5 months ago on August 31, 2024 at 11:05 am

hi , i need help with Inserting images as featured image on custom poste , 
i have a google sheet that contains all the fields i need to add , withing this fieds there are images urls located inside agoogle drive , each ro has his own imageurl . -the filde is sharable-
all the fields are imported normally , but the images nothing , and not set as featured image even if i selected it , i choosed remote url as this article saide : https://www.importwp.com/docs/how-to-import-attachments-from-google-drive/ 

J

James replied Support Agent

5 months ago on September 2, 2024 at 8:14 am

Hi Amor,

Can you please export and attach your importer settings to this ticket by going to Tools > Import WP > Settings / Tools > Import / Export and select and export your importer as a JSON file, plus any extra information i need to replicate your import locally to be able to fetch the google images.

James

aa

amor replied privately

5 months ago on September 2, 2024 at 5:35 pm

J

James replied Support Agent

5 months ago on September 2, 2024 at 7:53 pm

Can you provide the csv that you are importing or a row of that file that contains a featured image that is not importing, along with an export of your acf field groups to understand what youa re imprting to.

aa

amor replied privately

5 months ago on September 2, 2024 at 11:50 pm

J

James replied Support Agent

5 months ago on September 3, 2024 at 8:18 am

In your csv, you have only followed https://www.importwp.com/docs/how-to-import-attachments-from-google-drive/ to step 4, you need to convert the url in step 5 from this:

https://drive.google.com/file/d/1zjXO3_obgXBzN3oO7fEtTAnrwDhcQKEY/view?usp=drivesdk

to

https://drive.google.com/uc?export=download&id=12mTA2Ye0Oc3saQdvcs9TioFIBz-bsC8m

To save you having to convertall urls, you could use the following custom method:

function iwp_gd_attachment($input = '')
{
    if (preg_match('/https?:\/\/drive.google.com\/file\/d\/([^\/]+)/', $input, $matches) === 1) {
        return 'https://drive.google.com/uc?export=download&id=' . $matches[1];
    }

    return $input;
}

A guide on adding custom methods to your website can be found here: https://www.importwp.com/docs/using-code-snippets-in-wordpress/ , once the function has been added to your website, you can then use it in the importer, for example the csv you sent had the image in the first column, when selecting this in the importer it would be "{0}", to use this function you would change it to:

[iwp_gd_attachment("{0}")]

James