You are here:  » WordPress featured image

Active Forum Topics


WordPress featured image

Submitted by webblish on Mon, 2017-11-13 21:04 in

Hi, I'm bulding my first {link saved} with WP and PT. I've imported a product feed and I'm quite pleased with the result. My next challenge is to change the posts layout to a grid to give it a more 'e-commerce' look & feel.

But what I absutely need to achieve that is a solution for the image. In WP, it's not possible to use an external image as featured image. Also, a lot of themes absolutely need a featured image, otherwise there are no post images to show on the archive page. I tried some plugins to use the first post image as featured image with no result. What makes it more difficult is the fact that the link to the image is not u regular link, for example: {link saved}

How can I fix this?

Submitted by support on Tue, 2017-11-14 12:47

Hi,

Thank you for your comments!

When the imported posts are generated, they only contain the shortcodes necessary to generate the page as if in virtual mode - for example;

[pto product="Product Name"]
[pto prices="Product Name"]

So there would be no image within the post to be picked up automatically, however this can be added easily, by generating the image HTML directly into the post instead. To try this, first edit the Product / Main template (wp-admin > Settings > PriceTapestry.org) and remove the existing image markup:

%IF_IMAGE%
<div class='pto_col-s-10 pto_col-m-5 pto_pr-img'>
<img src='%IMAGE_URL%' />
</div>
%ENDIF_IMAGE%

Next, edit the plugin file pto_cron.php and look for the following code at line 33:

  $sql = "SELECT id,name,normalised_name,COUNT(id) as numMerchants FROM `".$pto_config_databaseTablePrefix."products` GROUP BY name ORDER BY name";

...and REPLACE with:

  $sql = "SELECT id,name,normalised_name,image_url,COUNT(id) as numMerchants FROM `".$pto_config_databaseTablePrefix."products` GROUP BY name ORDER BY name";

Edit pto.php and look for the following code at line 338:

        $sql = "SELECT id,name,normalised_name,COUNT(id) as numMerchants FROM `".$pto_config_databaseTablePrefix."products` GROUP BY name ORDER BY name LIMIT ".$start.",".$block;

...and REPLACE with:

        $sql = "SELECT id,name,normalised_name,image_url,COUNT(id) as numMerchants FROM `".$pto_config_databaseTablePrefix."products` GROUP BY name ORDER BY name LIMIT ".$start.",".$block;

Edit pto_common.php and look for the following code at line 261:

  $html = "<!-- pto -->";

...and REPLACE with:

  $html = "<!-- pto -->";
  if ($product->image_url)
  {
    $html .= "<p><img src='".$product->image_url."' /></p>";
  }

This has already come up in the beta feedback (/node/523) and I am looking at how best to implement this directly within the plugin, e.g. fetching the image URL, re-sizing and inserting into the media library and setting as the post thumbnail...

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by webblish on Thu, 2017-11-16 23:20

Hi, many thanks for the reply. Unfortunately, I can't locate the
$sql = "SELECT id,name,normalised_name,COUNT(id) as numMerchants FROM `".$pto_config_databaseTablePrefix."products` GROUP BY name ORDER BY name LIMIT ".$start.",".$block; in either the 2.0 or 3.0 version.

Submitted by support on Fri, 2017-11-17 08:15

Hi,

I had missed out a similar modification required for image_url inclusion in generated posts in pto_cron.php at line 33 - added above, but the change to pto.php at line 338 (version 3 since the imported option was added) is still required - however I did recently consolidate the importing / cron process in the latest beta version of version 3 so you may need to download the latest version.

If you have made other modification that you would like to preserve but you are not sure how to apply to the latest beta, let me know and I'll check it out further with you of course...

Cheers,
David.
--
PriceTapestry.com

Submitted by webblish on Tue, 2017-11-21 08:57

Well, I've changed the files exactly like you described, but the images are only visibible in the default themes (twenty seventeen etc), not in the theme(s) I like to use. I've tried several themes.

Submitted by support on Tue, 2017-11-21 10:20

Hi,

What I would suggest would be to make a test post in the theme you would like to use with just an image at the top of the post. Then view the page, and use your browser's View > Source function to see exactly what markup is surrounding the image URL in the post and replicate that in the above modification in place of;

     $html .= "<p><img src='".$product->image_url."' /></p>";

For example, maybe the image is output inside a div with class "post-image", so you might use:

     $html .= "<div class='post-image'><img src='".$product->image_url."' /></div>";

Cheers,
David.
--
PriceTapestry.com

Submitted by webblish on Tue, 2017-11-21 10:48

Before I do that, is it OK that the image source is a query? {link saved}

Submitted by support on Tue, 2017-11-21 10:51

That should be fine - as far as a browser is concerned it's just a URL - as long as it returns valid image data that's all that matters...

Cheers,
David.
--
PriceTapestry.com