I only saw a todo in the README, and haven't found much else. Please bare with me, as I'm coming to you as a designer.

Quite simply: what do I need to do to add my own custom icon sets? I'd like to avoid having to reupload these icons every time I update the module. I understand that I need to put the icon set in the libraries folder, but do I need to include, or alter, a file with identifying information?

Comments

Eudaimonstro’s picture

Would love some help here too.

alvgalrus’s picture

IMHO, this should be addressed as soon as possible.

Mike Dodd’s picture

Has anyone made any progress with this. I'm looking at this now but love some pointers if anyone has added a custom icon set

Mike Dodd’s picture

Hopefully this will help, its quite simple really:

add a custom callback for the iconset

function MODULE_NAME_social_media_links_iconset_info() {

    $set['SOCIAL_ICON_SET_NAME'] = array(
        'name' => 'SOCIAL_ICON_SET_NAME (REAL)',
        'publisher' => 'SOCIAL_ICON_SET_NAME (PUBLISHER)',
        'publisher url' => '',
        'styles' => array(
            '32' => '32x32',
        ),
        'path callback' => 'CUSTOM_CALLBACK',
        'download url' => '',
    );

    dpm($set, "s1");
    return $set;
}

add SOCIAL_ICON_SET_NAME to libraries with each icon inside and then add a function for the custom callback for any icon whos name is not simple like twitter.png

function CUSTOM_CALLBACK($platform = 'twitter', $style = '32') {
    $info = social_media_links_iconset('SOCIAL_ICON_SET_NAME');

    switch ($platform) {
        case 'contact':
            $platform = 'email';
            break;

        case 'googleplus':
            $platform = 'google';
            break;

        case 'youtube_channel':
            $platform = 'youtube';
            break;


    }

    $path = isset($info['path']) ? $info['path'] . '/' . $platform . '.png' : '';

    return $path;
}

Thats it flush the cache and then select your new icon set. Really quite simple :)

cbeier’s picture

@mike: Yes, that should work. But please note that the icon files must then also be places inside a valid library folder.

Example: If you new iconset is named "SOCIAL_ICON_SET_NAME", the icon file shoud be placed inside:

/sites/all/libraries/SOCIAL_ICON_SET_NAME/twitter.png

alvgalrus’s picture

But that approach won't solve the updating issue, as social_media_links.iconsets.inc will be overwritten with each update... Wouldn't be more straightforward to add a feature for scanning the folders inside "library"?

j0hnrigler’s picture

I was able to add links. All I did was edit the file $DRUPAL_HOME/sites/all/modules/social_media_links/social_media_links.platforms.inc and add some extra lines:

  $platforms['stackoverflow'] = array(
   'title' => t('StackOverFlow'),
   'base url' => 'http://stackoverflow.com/',
  );

  $platforms['github'] = array(
   'title' => t('GitHub'),
   'base url' => 'https://github.com/',
  );

I added them into the part of the code where other similar array entries were being made, then I added a 16x16 icon into the library section with the other images and re-edited the block. I could see my new entries and when I filled out something for them, they showed up. At one point, I typed a name wrong and got some nasty errors cached somewhere, but I simply disabled and re-enabled the module and these went away.

cbeier’s picture

@EmuAGR and @j0hnrigler: You must create a custom module. Inside your custom module then implement the documented hooks (e.g. MODULE_NAME_social_media_links_iconset_info()). Please see: Creating Drupal 7.x modules

cbeier’s picture

Status: Active » Fixed

I think we can close this support issue.

Should the problem not be resolved, please reopen.

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

@mike-dodd Many thanks for the code snippet. It worked perfectly!