The formatters override the default formaters, implying that all links have to go through shrinktheweb. However, in our use case, we only wanted some links to have the preview.

I have modified the hook_field_formatter_info() (see below) to prepend "stw_" to each formatter so that they don't override the default formatters, instead adding new formatters.

/**
 * Implementation of hook_field_formatter_info().
 */
function shrinktheweb_field_formatter_info() {
  return array(
    // -- Link module ----------------------------
    'stw_link_default' => array(
      'label' => t('[ShrinkTheWeb] Title, as link'),
      'field types' => array('link_field'),
      'multiple values' => FIELD_BEHAVIOR_DEFAULT,
    ),
    'stw_link_url' => array(
      'label' => t('[ShrinkTheWeb] URL, as link'),
      'field types' => array('link_field'),
      'multiple values' => FIELD_BEHAVIOR_DEFAULT,
    ),
    'stw_link_plain' => array(
      'label' => t('[ShrinkTheWeb] URL, as plain text'),
      'field types' => array('link_field'),
      'multiple values' => FIELD_BEHAVIOR_DEFAULT,
    ),
    'stw_link_short' => array(

      'label' => t('[ShrinkTheWeb] Short, as link with title "Link"'),
      'field types' => array('link_field'),
      'multiple values' => FIELD_BEHAVIOR_DEFAULT,
    ),
    'stw_link_label' => array(
      'label' => t('[ShrinkTheWeb] Label, as link with label as title'),
      'field types' => array('link_field'),
      'multiple values' => FIELD_BEHAVIOR_DEFAULT,
    ),
    'stw_link_separate' => array(
      'label' => t('[ShrinkTheWeb] Separate title and URL'),
      'field types' => array('link_field'),
      'multiple values' => FIELD_BEHAVIOR_DEFAULT,
    ),
  );
}
CommentFileSizeAuthor
#1 shrinktheweb_defaultformatters_1431206.patch1.65 KBAnonymous (not verified)

Comments

Anonymous’s picture

Providing a GIT patch for the index name changes

geobaev’s picture

Assigned: Unassigned » geobaev
Status: Active » Fixed

patch applied

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

odizle’s picture

Hi, I am having the same issue with the latest version, the default formats are missing. Cant seem to be able to patch it with this file.
Any Ideas?
Thanks

odizle’s picture

Hi Guys please help me solve this.
I have this issue and I have tried the patch with no luck so I have manually replace the code with the one supplied here, that made the display format show all other formats apart from [shrinktheweb] like title as link, but when choosing Shrinktheweb format it dose not the preview.
I love this module but would really like help with this fix. Thanks

gaëlg’s picture

Assigned: geobaev » Unassigned
Status: Closed (fixed) » Reviewed & tested by the community

This code fix is not present but still needed in the last 7.x-1.9 release.
But the theme functions need to be updated accordingly:
theme_shrinktheweb_formatter_link_no_text -> theme_shrinktheweb_formatter_stw_link_no_text
And the hook_theme implementation too.

  • SolomonGifford authored 5c9f619 on 7.x-1.x
    Issue #1431206 by solomongifford: Fixed overriding of default formatters...
devdokimov’s picture

Assigned: Unassigned » devdokimov

  • devdokimov committed 9864007 on 7.x-1.x
    Issue #1431206: Fix Shrink the Web formatters overwriting default Links...
devdokimov’s picture

Status: Reviewed & tested by the community » Closed (fixed)