0

I am using the Flippy Module to build an article pager on a client website.

Everything is working well, but I have encountered an issue where several thousand articles have been imported, many of which without an attached image. This of course disrupts Flippy as it sources its thumbnail from the article content type's image field.

Broken Image

Unfortunately Flippy doesn't appear to have any kind of no results behaviour built-in out of the box.

Anyone else encountered this issue too, or may be able to point me in the direction of a patch that may add this functionality to the module?

I would like to set a default image as a fall-back if no image is found.

TIA.

8
  • This of course disrupts Flippy as it sources its thumbnail from the article content type's image field. Have you tried setting a default image for your image field?
    – No Sssweat
    Commented Jun 3, 2016 at 9:19
  • Hi @Sssweat. Yeah that seems like the better approach since there will be an issue once those articles are also tagged and then pulled onto their categorised landing pages. Unfortunately a default image on the field was not set prior to the import. Is there a way to programmatically add a default image to all nodes that have already been created and which have an empty image field? Commented Jun 3, 2016 at 9:33
  • uploading a default image here should show the image regardless if the node is pre-existing, if I am not mistaken. Don't forget to clear the cache to see changes.
    – No Sssweat
    Commented Jun 3, 2016 at 9:42
  • As far as I know adding a default to the content type will only take effect to nodes created afterwards. For pre-existing nodes, it would require a per-node basis field update. One of my colleagues recommended doing a SQL injection to all nodes with an empty fid but this can be a bit risky. Commented Jun 3, 2016 at 9:54
  • 1
    As far as I know adding a default to the content type will only take effect to nodes created afterwards. That is true for text fields, but apperently it is not so for images. I just tried it and the default image shows up for pre-existing empty image field nodes. So give it a try.
    – No Sssweat
    Commented Jun 3, 2016 at 10:11

1 Answer 1

1

You can use flippy.tpl.php template. Copy this template in your theme and modify it what ever you want.

$image_arr = array(
        'path' => $file->uri,
        'style_name' => '<Style Name>',
        'alt' => '',
        'title' => '',
      ); 

print theme('image_style', $image_arr);
2
  • Hi @Nagarjuna yeah I looked at the Flippy tpl as a possible solution. I will just need to create an argument so that it only prints a default image if it tries to source from an empty image fid and not override all nodes that do have an image. Commented Jun 3, 2016 at 10:32
  • you can just pass node id to template_preprocess_hook and then use node_load to get the all fields. Cheers :)
    – NTT
    Commented Jun 3, 2016 at 10:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.