Make a specific image on profiles display on every page
3 posters
Page 1 of 1
Make a specific image on profiles display on every page
Hello all,
So my question is the following:
I have a profile field where the user is able to edit the field and change the image anytime (s)he wishes. The fields code is this one:
So the
is an image that is added to the profile information as a cover photo (same as Facebook cover photos) but this only stays on the profile tab.
I want this entire table code to go to each tab while viewing a member profile so that it stays on the top.
Here's a demo of what i mean:
Any help would be appreciated. Thank you.
So my question is the following:
I have a profile field where the user is able to edit the field and change the image anytime (s)he wishes. The fields code is this one:
- Code:
[table class="coverPhoto" id="cvP"][tr][td][img]https://i58.servimg.com/u/f58/19/06/26/04/cover10.png[/img][/td][/tr][/table]
So the
|
I want this entire table code to go to each tab while viewing a member profile so that it stays on the top.
Here's a demo of what i mean:
Any help would be appreciated. Thank you.
Re: Make a specific image on profiles display on every page
Hi @Luffy,
You can use AJAX to get the main profile page, then find and use the element from the response. Here's a quick example using get() :
If any questions, let me know.
You can use AJAX to get the main profile page, then find and use the element from the response. Here's a quick example using get() :
- Code:
if (/\/u\d+[a-z]+/.test(window.location.href)) { // executes on any profile page EXCEPT where the profile fields are
$.get('/u' + window.location.href.replace(/.*?\/u(\d+).*/, '$1'), function (data) {
var cover = $('.coverPhoto img', data)[0];
if (cover) {
// do something with the cover image
// console.log(cover, cover.src);
}
});
}
If any questions, let me know.
Re: Make a specific image on profiles display on every page
So i can do this with the entire table right @Ange Tuteur?
Forum of the Forums Forumotion Rules | Tips & Tricks | FAQ | Did you forget your password? |
*** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
No support via PM!
Re: Make a specific image on profiles display on every page
Yeah, just remove "img" from the selector
, so you get this :
You can of course select other stuff that's present on the page by using data as the second param in jQuery's query selection. ex :
|
- Code:
if (/\/u\d+[a-z]+/.test(window.location.href)) { // executes on any profile page EXCEPT where the profile fields are
$.get('/u' + window.location.href.replace(/.*?\/u(\d+).*/, '$1'), function (data) {
var cover = $('.coverPhoto', data)[0];
if (cover) {
// do something with the cover image
// console.log(cover);
}
});
}
You can of course select other stuff that's present on the page by using data as the second param in jQuery's query selection. ex :
|
Re: Make a specific image on profiles display on every page
I managed to do that work but now there is a tiny problem to this.
Once someone changed the code in the field, it shows the image in the field and they have to refresh to see the cover as it has to be, is there a way that once someone hits the send on that field and only to refresh the page? Or something else that will not show like this for example?
Once someone changed the code in the field, it shows the image in the field and they have to refresh to see the cover as it has to be, is there a way that once someone hits the send on that field and only to refresh the page? Or something else that will not show like this for example?
Forum of the Forums Forumotion Rules | Tips & Tricks | FAQ | Did you forget your password? |
*** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
No support via PM!
Re: Make a specific image on profiles display on every page
The best solution would be to bind an event to the document so that when you click the save check mark it updates the banner. Something like this :
So that it triggers your function that updates the banner image, I'd recommend naming your function so that it can be called multiple times. Here's a quick example of a named function :
If you need any help let me know.
- Code:
$(document).on('click', '#field_id-12 .ajax-profil_valid', function () {
alert('Saved');
});
So that it triggers your function that updates the banner image, I'd recommend naming your function so that it can be called multiple times. Here's a quick example of a named function :
- Code:
function sayHi () {
alert('Hi');
};
$(sayHi); // execute "sayHi" on doc ready
$(document).on('click', '#field_id-12 .ajax-profil_valid', sayHi); // execute "sayHi" when the profile field is updated
If you need any help let me know.
Re: Make a specific image on profiles display on every page
And the function you're saying, is it the one that edits the field?
Okay so i made it differently and now it reloads while verifying the field by using this:
- Code:
$(document).on('click', '#field_id2 .ajax-profil_valid', function () {
alert('Saved! Please hold on while reloading.');
$('.coverPhoto img').css('display','none');
window.location.reload(true)
});
Thanks so much @Ange Tuteur.
Forum of the Forums Forumotion Rules | Tips & Tricks | FAQ | Did you forget your password? |
*** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
No support via PM!
Re: Make a specific image on profiles display on every page
Ah, that'll work. I was assuming you set the cover image behind the profile via JS, which is why I recommended using a named function that can be recalled to update it.
You're welcome btw. Have a good weekend.
You're welcome btw. Have a good weekend.
Re: Make a specific image on profiles display on every page
I tried that but i couldn't change the new image's location and that's why i did the above!Ange Tuteur wrote:Ah, that'll work. I was assuming you set the cover image behind the profile via JS, which is why I recommended using a named function that can be recalled to update it.
You're welcome btw. Have a good weekend.
Forum of the Forums Forumotion Rules | Tips & Tricks | FAQ | Did you forget your password? |
*** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
No support via PM!
Re: Make a specific image on profiles display on every page
Problem solved as requsted by @Luffy & topic archived.
|
Similar topics
» How can i use CSS to make a rollover for text to display a image
» How to make a box around the profiles.
» How do I make someone or a specific group in charge of a specific forum/category?
» [Solved] Make specific hover change for specific topics.
» Is there a way I can make it so only I, an admin, can make threads in a specific forum?
» How to make a box around the profiles.
» How do I make someone or a specific group in charge of a specific forum/category?
» [Solved] Make specific hover change for specific topics.
» Is there a way I can make it so only I, an admin, can make threads in a specific forum?
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum