JQuery, Javascript and CSS tips, tricks and hacks

Copy paste images to CKeditor body field like on Medium

By default you can't copy and paste images from clipboard to text field using CKeditor, I would argue this should even be in core as if you are writing an article this would be very useful to have, even more then what "Media" module brings. So how to add this to drupal. Well not easy as usual :)

How to get which CKEditor version is your drupal installation running?

There is a simple way to do this over dev tools in browser, just to to "node edit" or a place where CKEditor is active and run

alert(CKEDITOR.version);

and you will get the version. Currently, it is at 4.14.1 which is almost the latest in 4.x versions, but there is also 5.x version that drupal is still not using.

Can't find a string to translate in drupal

This is kind of odd solution as it will confuse people.

"The t() function, to save on performance for single-language sites, won't store the string in the database until it is requested from another language. View the page in one of the non-default languages in order to populate the database (t() calls locale() to do this), thus making the string available for translation."

Insert something every nth row in Views

Most likely you will want to insert an ADD, probably adsense add every nth row in views. To do that there are 3 methods. One of them is a module a guy made that acts as global filed you add and then you enter what goes in there, problem is that JS code doesnt work there as it is html only field, so some custom formatters should be added.

Add UTM tag to links, so other people know when users come from your site

So this is some marketing stuff I do, but it is useful. When you click a link on some site, to give some message to that site and owner or whoevere is taking care of marketing you can add some UTM tags to links so in their google analytics they see that message. So what do we do is I use display suite, create custom code field and use entity data to make new fields that look like this:

Translating paths

I have got this panel, that has the same content for both English and Croatian. But I want to have custom path for each of them, so that address bar doesn't say something on Croatian when user interface is in English.

Authoring information and permissions

User 1 has all the privilegies. But for other you need to set them. If you want that user has ability to change who authored node you will need to give him "administer nodes" permission. Usually overlooked, this permission is unde node module permission set.

Fusion theme classes for node add and node edit pages

I almost always use Fusion theme as my base theme, one thing its missing and developers of it seem not to care is a class that is in body and is different for node add and node edit pages, so I usually go to template.php and around line 64, after